V: Non-string map keys

Created on 28 Nov 2020  路  8Comments  路  Source: vlang/v

Most helpful comment

I've spoken to @ka-weihe on Discord and he suggested a good optimization when there are no deleted keys, so my work will be compatible with that.

Speaking of optimization, the check for existence in a "static" map (if x in mymap_with_just_unconditional_values_added) or array (if x in [ 'a', 'b', 'c' ]) can be "extremely" optimized by using optimal hashing.

All 8 comments

I'm interested in working on this, anyone else? I think the key type would need a hash method and* an equals function. (For autofree also an optional clone method).

* actually the general-purpose hash is probably enough.

@ntrel good luck!

@ka-weihe can give some hints and answer questions about the implementation.

@ka-weihe can give some hints and answer questions about the implementation.

For sure. @ntrel feel free to contact me on discord (I'm "Kasper W" on V's discord).

Beware non-string maps will amplify the undefined behavior of equals() for floats.

I'm working on making DenseArray support non-string keys first, with map still using string keys. When that's done I can make a pull request.

I've spoken to @ka-weihe on Discord and he suggested a good optimization when there are no deleted keys, so my work will be compatible with that.

I've spoken to @ka-weihe on Discord and he suggested a good optimization when there are no deleted keys, so my work will be compatible with that.

Speaking of optimization, the check for existence in a "static" map (if x in mymap_with_just_unconditional_values_added) or array (if x in [ 'a', 'b', 'c' ]) can be "extremely" optimized by using optimal hashing.

@dumblob that is correct and I think we will eventually do that optimization along with a huge list of other optimizations, but right now the focus is strictly on non-string keys 馃檪

DenseArray is now string-free. I'm working on encapsulating the other operations on a key with functions taking voidptr.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cjmxp picture cjmxp  路  3Comments

markgraydev picture markgraydev  路  3Comments

choleraehyq picture choleraehyq  路  3Comments

clpo13 picture clpo13  路  3Comments

jtkirkpatrick picture jtkirkpatrick  路  3Comments