From 2d5980b406fc1efaa63b8f18bcc1b25ab8ec8268 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 14 Apr 2016 08:43:06 -0700 Subject: 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. --- src/pugixml.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') 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 -- cgit v1.2.3