summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-04-14 08:43:06 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-04-14 08:43:06 -0700
commit2d5980b406fc1efaa63b8f18bcc1b25ab8ec8268 (patch)
tree54b0f5b102782f9f3a39d43c4b2de67cb95b42b0
parent2e0ed8284b7488f9664bf8dba9aae90688862cc3 (diff)
Adjust XML allocation pages to have the exact specified size
Previously the page size was defining the data size, and due to additional headers (+ recently removed allocation padding) the actual allocation was a bit bigger. The problem is that some allocators round 2^N+k allocations to 2^N+M, which can result in noticeable waste of space. Specifically, on 64-bit OSX allocating the previous page size (32k+40) resulted in 32k+512 allocation, thereby wasting 472 bytes, or 1.4%. Now we have the allocation size specified exactly and just recompute the available data size, which can in small space savings depending on the allocator.
-rw-r--r--src/pugixml.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index e8c10a7..fc48701 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -403,14 +403,6 @@ PUGI__NS_END
#endif
PUGI__NS_BEGIN
- static const size_t xml_memory_page_size =
- #ifdef PUGIXML_MEMORY_PAGE_SIZE
- PUGIXML_MEMORY_PAGE_SIZE
- #else
- 32768
- #endif
- ;
-
#ifdef PUGIXML_COMPACT
static const uintptr_t xml_memory_block_alignment = 4;
#else
@@ -476,6 +468,14 @@ PUGI__NS_BEGIN
#endif
};
+ static const size_t xml_memory_page_size =
+ #ifdef PUGIXML_MEMORY_PAGE_SIZE
+ (PUGIXML_MEMORY_PAGE_SIZE)
+ #else
+ 32768
+ #endif
+ - sizeof(xml_memory_page);
+
struct xml_memory_string_header
{
uint16_t page_offset; // offset from page->data