| 26 | } |
| 27 | |
| 28 | void vector_basic::trivial_swap(void* a, void* b) const { |
| 29 | // Stack buffer for small elements, heap for large |
| 30 | char stack_buf[64]; |
| 31 | void* tmp; |
| 32 | bool heap_allocated = false; |
| 33 | if (mElementSize <= sizeof(stack_buf)) { |
| 34 | tmp = stack_buf; |
| 35 | } else { |
| 36 | tmp = mResource->allocate(mElementSize); |
| 37 | heap_allocated = true; |
| 38 | } |
| 39 | fl::memcpy(tmp, a, mElementSize); |
| 40 | fl::memcpy(a, b, mElementSize); |
| 41 | fl::memcpy(b, tmp, mElementSize); |
| 42 | if (heap_allocated) { |
| 43 | mResource->deallocate(tmp, mElementSize); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // ======= CAPACITY / GROWTH ======= |
| 48 |
nothing calls this directly
no test coverage detected