summaryrefslogtreecommitdiff
path: root/python/examples/breakpoint.py
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2024-11-22 19:04:37 -0800
committerMason Reed <mason@vector35.com>2025-02-12 18:43:02 -0500
commitc9bbe933dd53fff5d54c2e4f218e4a89f6c58fcd (patch)
tree1f9702e7ccb2902b9f44a0222e72391670782dfd /python/examples/breakpoint.py
parentc20bf355152d9a715dae3c19777c3d4a1046174b (diff)
[SharedCache] Simplify MMappedFileAccessor::Read* methods
This change is mostly motivated by simplifying the code, but it also brings minor correctness and performance benefits. 1. The pointer returned by mmap is stored as a uint8_t* rather than void* as that is how it is used. This reduces how often it needs to be cast to a different type before it is used. 2. Read methods for primitives delegate to a new Read template function that in turn delegates to the general-purpose `Read(void* dest, size_t address, size_t length)`. This improves the consistency of bounds checking and simplifies the code. The compiler is more than willing to inline this so we get less repetition with no overhead. 3. ReadNullTermString now uses std::find to find the nul byte and directly constructs the string from that range of bytes. This removes an unnecessary allocation that was previously being forced by the use reserve followed by shrink_to_fit. It also avoids repeated reallocation for longer strings as they grew past the the reserved size as they were being built up a character at a time.
Diffstat (limited to 'python/examples/breakpoint.py')
0 files changed, 0 insertions, 0 deletions