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.
This commit is contained in:
parent
2e0ed8284b
commit
2d5980b406
@ -403,14 +403,6 @@ PUGI__NS_END
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
PUGI__NS_BEGIN
|
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
|
#ifdef PUGIXML_COMPACT
|
||||||
static const uintptr_t xml_memory_block_alignment = 4;
|
static const uintptr_t xml_memory_block_alignment = 4;
|
||||||
#else
|
#else
|
||||||
@ -476,6 +468,14 @@ PUGI__NS_BEGIN
|
|||||||
#endif
|
#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
|
struct xml_memory_string_header
|
||||||
{
|
{
|
||||||
uint16_t page_offset; // offset from page->data
|
uint16_t page_offset; // offset from page->data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user