Added NumString, usize based string
- Added usize based string
- Added it to benchmarks
- it's a LOT faster than SmallString.
- still missing most functions and a bit of docs, but nothing to large, just copy paste the array_string ones.
Pretty cool trick, seems promising! Does that also work with u128, and possibly with multiple fields? So we can get a bigger string than 8 ASCII characters? Is usize instead of u64 intentional btw?
There seems to be a lot of future in this!
Usize guarantees maximum speed as it will always be a register. U64 seems natural but in the end numtraits are not the way to go. Maybe i'll try a generalized case since consts are not stable enough to be used effectively. We could do u128 without issues but i expect it to be a lot slower. In essence all that is needed is a bit field since all that is done is shifting things around while preserving endianness for instant str transmute.
In my benchmark it took 1 cycle to copy, 4 cycles to from_str, 5 cycles to push_str. It will be pretty hard to beat that, at least on an arm cpu. For u128 each operation on x86 using sse is 2 cycles on most cpus, but there could be sse magic to shave a few instructions so it could be almost as fast as the usize one.
It would also be worth it to test on terget arch=native, and maybe even with avx 2 256 bit registers. (512 is just too rare to test)