Skip to content

addAndGetMenuItem is suprisingly slow #166

@ericu

Description

@ericu

I was profiling to figure out why an operation in my code was slow, and it turned out that it wasn't at all--it was that I was updating a few menus with the result of the operation. Apparently down inside addAndGetMenuItem in my app there are 32454 calls to getMenuItemByIndex'. I do have a lot of stuff in my menus [I generate them based on what's in my database, so that you can select from any defined item]; it looks like I have somewhere north of 8000 of them, though far less than 32K. Here I'm updating a submenu with about a dozen entries by clearing it, putting back the standard items, and adding a new one to represent a newly-created object. What's the fast way to do this, or can addAndGetMenuItem be sped up?

The reason I'm using addAndGetMenuItem is to have a handle to the menu item [a toggle button] so that I can call "set" on it if it's the active item. If I could just add it with some flag that makes it set, I'd do that instead, but I don't see a flag for that. Perhaps I'm missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions