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

Function GetHostAndPortImpl

library/cpp/string_utils/url/url.cpp:165–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164template <bool KeepPort>
165static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
166 TStringBuf urlNoScheme = url;
167
168 urlNoScheme.Skip(GetHttpPrefixSize(url));
169
170 struct TDelim: public str_spn {
171 inline TDelim()
172 : str_spn(KeepPort ? "/;?#" : "/:;?#")
173 {
174 }
175 };
176
177 const auto& nonHostCharacters = *Singleton<TDelim>();
178 const char* firstNonHostCharacter = nonHostCharacters.brk(urlNoScheme.begin(), urlNoScheme.end());
179
180 if (firstNonHostCharacter != urlNoScheme.end()) {
181 return urlNoScheme.substr(0, firstNonHostCharacter - urlNoScheme.data());
182 }
183
184 return urlNoScheme;
185}
186
187TStringBuf GetHost(const TStringBuf url Y_LIFETIME_BOUND) noexcept {
188 return GetHostAndPortImpl<false>(url);

Callers

nothing calls this directly

Calls 7

GetHttpPrefixSizeFunction · 0.85
brkMethod · 0.80
SkipMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
substrMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected