| 892 | nextReadLocation(-1), readBufPage(nullptr), readBufPos(0) {} |
| 893 | |
| 894 | location push(StringRef contents) override { |
| 895 | ASSERT(recovered); |
| 896 | uint8_t const* begin = contents.begin(); |
| 897 | uint8_t const* end = contents.end(); |
| 898 | CODE_PROBE(contents.size() && pushedPageCount(), "More than one push between commits"); |
| 899 | |
| 900 | bool pushAtEndOfPage = contents.size() >= 4 && pushedPageCount() && backPage().remainingCapacity() < 4; |
| 901 | CODE_PROBE(pushAtEndOfPage, "Push right at the end of a page, possibly splitting size"); |
| 902 | while (begin != end) { |
| 903 | if (!pushedPageCount() || !backPage().remainingCapacity()) |
| 904 | addEmptyPage(); |
| 905 | |
| 906 | auto& p = backPage(); |
| 907 | int s = std::min<int>(p.remainingCapacity(), end - begin); |
| 908 | memcpy(p.payload + p.payloadSize, begin, s); |
| 909 | p.payloadSize += s; |
| 910 | begin += s; |
| 911 | } |
| 912 | return endLocation(); |
| 913 | } |
| 914 | |
| 915 | void pop(location upTo) override { |
| 916 | ASSERT(!upTo.hi); |
no test coverage detected