MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / String

Function String

native/thirdpart/flatbuffers/flexbuffers.h:1028–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026 size_t Key(const std::string &str) { return Key(str.c_str(), str.size()); }
1027
1028 size_t String(const char *str, size_t len) {
1029 auto reset_to = buf_.size();
1030 auto sloc = CreateBlob(str, len, 1, FBT_STRING);
1031 if (flags_ & BUILDER_FLAG_SHARE_STRINGS) {
1032 StringOffset so(sloc, len);
1033 auto it = string_pool.find(so);
1034 if (it != string_pool.end()) {
1035 // Already in the buffer. Remove string we just serialized, and use
1036 // existing offset instead.
1037 buf_.resize(reset_to);
1038 sloc = it->first;
1039 stack_.back().u_ = sloc;
1040 } else {
1041 string_pool.insert(so);
1042 }
1043 }
1044 return sloc;
1045 }
1046 size_t String(const char *str) { return String(str, strlen(str)); }
1047 size_t String(const std::string &str) {
1048 return String(str.c_str(), str.size());

Callers 3

EmptyStringMethod · 0.70
AsStringMethod · 0.70
AddFunction · 0.70

Calls 6

CreateBlobFunction · 0.85
KeyFunction · 0.85
lengthMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected