From: Florin T. <fl...@gm...> - 2010-01-20 23:15:40
|
Hello, I know any_regular_t has in-object allocation for types smaller than 8 bytes (64 bits). Larger types are allocated on the heap. Consider this scenario: BigObject obj; // 56 bytes->heap any_regular_t value(obj); [...] SmallerObject obj2; // 24 bytes value.assign(obj2); // destroys current object and re-allocates I looked at how any_regular_t::assign is implemented and it tries to preserve its capacity if the new type is the same as the existing one. If not, it destroys the guts of the current object and re-allocates. Since heap allocations are expensive and a major bottleneck for scalability I was wondering if anybody considered worth implementing an optimization that checks if the current capacity is enough when re-assigning. A reserve() and clear() methods would be a nice bonus. Best regards, Florin |