[Development] RFC: new moc feature

Knoll Lars Lars.Knoll at theqtcompany.com
Thu Jan 7 08:38:10 CET 2016


On 06/01/16 18:38, "Development on behalf of Kevin Kofler" <development-bounces at qt-project.org on behalf of kevin.kofler at chello.at> wrote:



>Knoll Lars wrote:
>> Just as a side note: While perf ensures there’s no collisions between
>> valid keys in the hash table, you still end up doing one string comparison
>> in the end to ensure that your input string matches the key.
>
>Why? Just document that passing an unknown string is undefined behavior, 
>then if your invalid input happens to collide with the hash of something 
>valid, it'll just be a synonym, undefined means undefined.

Because that leads to completely unpredictable behaviour for any user. A simple typo in your input string and you might get whatever result. The only case where this is acceptable is if you can guarantee through external means that the string you parse will only ever contain valid keys. But it’s certainly nothing you want in more general purpose library code or the example Sean mentioned.

Lars



More information about the Development mailing list