Re:Stop Memsetting Structures
by a_t48 on Saturday April 27, 2019 @06:24PM
(#19768006)
That's a pretty classical file serialization trick to pack a bunch of heterogeneous data in one file. A header/manifest starting the file, with an array of names, offsets, and sizes.
[ Parent
| on HN ]
Re:Stop Memsetting Structures
by blattimwind on Saturday April 27, 2019 @09:02PM
(#19768657)
Actually works somewhat well for mmap'ed access, too, by using a macro or function to "dereference" "pointers" (offsets).
Or even an OffsetPtr class with overloaded arrow and dereference operator, if you swing that way. :)
Re:Stop Memsetting Structures
by DaiPlusPlus on Sunday April 28, 2019 @08:59AM
(#19770921)
What’s the runtime performance of that in-practice? Does x86, x64 and ARM have support for relative offset pointers without any performance impact? And do compilers use them?
Re:Stop Memsetting Structures
by blattimwind on Sunday April 28, 2019 @12:38PM
(#19772073)
Yes, address generation can at the very least do [reg + constant], and on x86, much much more. These are bread and butter optimizations constantly used by compilers all over the place, because this is how field access works.