3 ms·
> They are bigint-encoding identifiers? There is no sane reason to do this. There needn't be any "encoding" really. Modern CPUs have a 32-bit compare instructi
by crucini 10y ago
> They are bigint-encoding identifiers? There is no sane reason to do this.
There needn't be any "encoding" really. Modern CPUs have a 32-bit compare instruction. The CPU doesn't understand types as a compiler does; it will accept any aligned series of 4 bytes as a comparand. Some implementations of strcmp use that. Forcing the identifiers to 4 bytes eliminates some if-else edge casing before the compare, which might speed things up.
Disclaimer: I don't know anything about urbit. I agree such an optimization is surprising. The more normal pattern is to convert human-readable symbols to integers early, thus avoiding string comparison in performance-critical sections.