MCPcopy Create free account
hub / github.com/catboost/catboost / GetSchemePrefixSize

Function GetSchemePrefixSize

library/cpp/string_utils/url/url.cpp:134–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134size_t GetSchemePrefixSize(const TStringBuf url) noexcept {
135 if (url.empty()) {
136 return 0;
137 }
138
139 struct TDelim: public str_spn {
140 inline TDelim()
141 : str_spn("!-/:-@[-`{|}", true)
142 {
143 }
144 };
145
146 const auto& delim = *Singleton<TDelim>();
147 const char* n = delim.brk(url.data(), url.end());
148
149 if (n + 2 >= url.end() || *n != ':' || n[1] != '/' || n[2] != '/') {
150 return 0;
151 }
152
153 return n + 3 - url.begin();
154}
155
156TStringBuf GetSchemePrefix(const TStringBuf url Y_LIFETIME_BOUND) noexcept {
157 return url.Head(GetSchemePrefixSize(url));

Callers 5

GetSchemePrefixFunction · 0.85
CutSchemePrefixFunction · 0.85
GetSchemeHostFunction · 0.85
GetSchemeHostAndPortFunction · 0.85
TryGetSchemeHostAndPortFunction · 0.85

Calls 5

brkMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected