MCPcopy Create free account
hub / github.com/apache/brpc / SetString

Method SetString

src/brpc/amf.cpp:143–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void AMFField::SetString(const butil::StringPiece& str) {
144 // TODO: Try to reuse the space.
145 Clear();
146 if (str.size() < SSO_LIMIT) {
147 _type = AMF_MARKER_STRING;
148 _is_shortstr = true;
149 _strsize = str.size();
150 memcpy(_shortstr, str.data(), str.size());
151 _shortstr[str.size()] = '\0';
152 } else {
153 _type = (str.size() < 65536u ?
154 AMF_MARKER_STRING : AMF_MARKER_LONG_STRING);
155 char* buf = (char*)malloc(str.size() + 1);
156 memcpy(buf, str.data(), str.size());
157 buf[str.size()] = '\0';
158 _is_shortstr = false;
159 _strsize = str.size();
160 _str = buf;
161 }
162}
163
164void AMFField::SetBool(bool val) {
165 if (_type != AMF_MARKER_BOOLEAN) {

Callers 13

RunMethod · 0.45
TEST_FFunction · 0.45
DoGetMethod · 0.45
DoGetMethod · 0.45
TESTFunction · 0.45
RunMethod · 0.45
FillSlotEntryMethod · 0.45
RunMethod · 0.45
JsonValueToProtoFieldFunction · 0.45
JsonMapToProtoMapFunction · 0.45
AddStringMethod · 0.45
ReadAMFObjectFieldFunction · 0.45

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by 7

TEST_FFunction · 0.36
DoGetMethod · 0.36
DoGetMethod · 0.36
TESTFunction · 0.36
RunMethod · 0.36
FillSlotEntryMethod · 0.36
RunMethod · 0.36