MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Reset

Method Reset

CodeFormatServer/src/Session/Protocol/ProtocolBuffer.cpp:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void ProtocolBuffer::Reset() {
53 if (_writeIndex > _contentLength + _bodyStartIndex) {
54 std::size_t doneIndex = _contentLength + _bodyStartIndex;
55 std::copy_n(_textProtocol.data() + doneIndex, _writeIndex - doneIndex, _textProtocol.data());
56
57 _writeIndex -= doneIndex;
58 if (_writeIndex > _normalCapacity) {
59 _textProtocol.resize(_writeIndex);
60 _textProtocol.shrink_to_fit();
61 } else {
62 _textProtocol.resize(_normalCapacity);
63 _textProtocol.shrink_to_fit();
64 }
65 } else {
66 _writeIndex = 0;
67 if (_textProtocol.size() > _normalCapacity) {
68 _textProtocol.resize(_normalCapacity);
69 _textProtocol.shrink_to_fit();
70 }
71 }
72
73 _contentLength = 0;
74 _bodyStartIndex = 0;
75}
76
77bool ProtocolBuffer::TryParseHead() {
78 enum class ParseState {

Callers 2

RunMethod · 0.45
RunMethod · 0.45

Calls 3

dataMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected