Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
Why on earth are we hashing window names?
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
The "name" is only used as an id for the window. So we hash it on creation of the window. Then, nk_find_window() (which is called all the time), looks for a matching window hash (recreating the hash): and then checks the name (running strlen again!).
Would it not make a whole lot more sense to say, "use a unique integer identifier" for each window (or other item that needs an id), and just store that id ... thereby not needed to do a hash nor compare strings nor do strlen just to find a window?
You could even have a "nk_unique_id()" to return, per context, a new int that is unique (just increment a counter). No need to be fancy.
What am I missing?
Contributor guide
Research direction
Start by tracing window creation and nk_find_window(), focusing on where names are hashed, compared, and measured. Determine whether a context-scoped unique integer can preserve the existing lookup behavior; done requires a maintainer-approved design, since the issue currently poses a question rather than specifying an implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100