KoID is an ID with a translatable string associated with it. It's used all over the place as a way to uniquely identify things. Unfortunately the ID itself is a QString, which is not great for performance.
There are a number of ways this can be improved. A common one is to hash strings and use the result in code. The exact solution depends on what limitations are acceptable, so the first step is to figure out what use-cases we need to support.
These are the requirements of KoID I've gathered so far:
- Each ID has to be unique
- Each ID has to map to one translatable string
- Translatable strings do not have to be unique, i.e. multiple IDs can map to identical translatable strings
- IDs have to be deterministic within the same version; building and running Krita multiple times from the same source should produce identical IDs
- IDs have to be comparable and sortable
- KoID has to be serializable in a forward and backward compatible manner, i.e. writing an ID to disk in one version of Krita and loading it in another have to map to the same source ID definition
- KoID has to be QMetaType compatible (http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE)
- Runtime KoID creation has to be supported (?) [Note: This is based on usage where KoIDs are created from settings files. If those strings are known at compile time this requirement can be removed]