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

Function to_underscored_name

src/bvar/variable.cpp:942–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940 &FLAGS_mbvar_dump_format, validate_mbvar_dump_format);
941
942void to_underscored_name(std::string* name, const butil::StringPiece& src) {
943 name->reserve(name->size() + src.size() + 8/*just guess*/);
944 for (const char* p = src.data(); p != src.data() + src.size(); ++p) {
945 if (isalpha(*p)) {
946 if (*p < 'a') { // upper cases
947 if (p != src.data() && !isupper(p[-1]) &&
948 butil::back_char(*name) != '_') {
949 name->push_back('_');
950 }
951 name->push_back(*p - 'A' + 'a');
952 } else {
953 name->push_back(*p);
954 }
955 } else if (isdigit(*p)) {
956 name->push_back(*p);
957 } else if (name->empty() || butil::back_char(*name) != '_') {
958 name->push_back('_');
959 }
960 }
961}
962
963// UT don't need default variables.
964#if !defined(BVAR_NOT_LINK_DEFAULT_VARIABLES)

Callers 5

UpdateDerivedVarsMethod · 0.85
expose_implMethod · 0.85
read_command_nameFunction · 0.85
FileDumperMethod · 0.85
expose_implMethod · 0.85

Calls 6

back_charFunction · 0.85
reserveMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected