invertedtomato / packing

Library for encoding integers in the minimal number of bits. Includes VLQ and Elias Omega encoding.
MIT License
76 stars 6 forks source link

Constrainted generics for higher perfromance #12

Closed dzmitry-lahoda closed 5 years ago

dzmitry-lahoda commented 5 years ago

May consider replace

public override void EncodeMany(IByteWriter stream, UInt64[] values, Int32 offset, Int32 count)

with

public override void EncodeMany<T>(T stream, UInt64[] values, Int32 offset, Int32 count)
where T:IByteWriter 

It may improve performance.

https://github.com/invertedtomato/integer-compression/blob/8b0b80f1e74340b90cc9726c1bf944dbca93b24d/Library/Compression/Integers/Wave3/FibonacciCodec.cs#L37

invertedtomato commented 5 years ago

Hey Dzimitry, do you have any performance benchmarks for this kind of optimization? I would have expected them to be similar!

dzmitry-lahoda commented 5 years ago

I will recheck my memory regarding this case. May be I over complicate. Also I dislike override. Will test both item.

invertedtomato commented 5 years ago

I'm not too much of a fan of override myself, but it does seem to be the right tool in this case.

dzmitry-lahoda commented 5 years ago

will check this today to benchmarks.