Closed raydefy closed 4 years ago
I need to think about this more, but my initial question is why not use pack / unpack (or marshal) to convert to a string?
I was planning on using mmap to share performance counters from a Ruby program with another program. I don't know if there is any performance benefit to avoiding pack/unpack. I should have tested that.
In any case, I sized the Int as a byte. It should have been at least 4 bytes. The pack/unpack would avoid all that non-sense.
Upon reflection, I think the pack/unpack is a perfect Ruby approach. We don't need to complicate the API by making Integer any more special than they already are.
Here we see the exact use case I was working toward. But he ditches mmap for a file. https://www.youtube.com/watch?v=crbyeyPS7HE&list=TLPQMTgxMjIwMTmkP6JczWLARQ&index=2
I needed to share integers between two processes and wanted to use mmap. While it supports #insert of strings, it did not support the same for numbers. I'm note sure I sized things right, but the tests pass.