MatrixAI / js-id

ID generation for JavaScript & TypeScript Applications
https://polykey.com
Apache License 2.0
10 stars 1 forks source link

Optimise IdSortable by using bitwise operations on a Unit32Array with size 4 #4

Open CMCDragonkai opened 2 years ago

CMCDragonkai commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently IdSortable uses bitstrings for construction. This is a bit inefficient. We can use a size 4 Uint32Array and do bitwise operations instead.

Describe the solution you'd like

Have to ensure that we handle the non-aligned bits. Some right shift and left shift should be appropriate.

This shouldn't affect decoding.

CMCDragonkai commented 2 years ago

Benchmarks should be done to ensure that we can actually test how more performance it is.