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

Function ToTitle

util/charset/wide.cpp:239–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239bool ToTitle(TUtf16String& text, size_t pos, size_t count) {
240 if (!text) {
241 return false;
242 }
243
244 pos = pos < text.size() ? pos : text.size();
245 count = count < text.size() - pos ? count : text.size() - pos;
246
247 const auto toLower = [](const wchar32 s) { return ToLower(s); };
248
249 auto* p = const_cast<wchar16*>(text.data() + pos);
250 const auto* pe = text.data() + pos + count;
251
252 const auto firstSymbol = ReadSymbol(p, pe);
253 if (firstSymbol == ToTitle(firstSymbol)) {
254 p = SkipSymbol(p, pe);
255 if (ModifySequence<true>(p, pe, toLower)) {
256 DetachAndFixPointers(text, p, pe);
257 ModifySequence<false>(p, pe, toLower);
258 return true;
259 }
260 } else {
261 DetachAndFixPointers(text, p, pe);
262 WriteSymbol(ToTitle(ReadSymbol(p, pe)), p); // also moves `p` forward
263 ModifySequence<false>(p, pe, toLower);
264 return true;
265 }
266
267 return false;
268}
269
270bool ToTitle(TUtf32String& text, size_t pos, size_t count) {
271 if (!text) {

Callers 6

TestUnicodeCaseMethod · 0.70
TestWideStringMethod · 0.70
TestToTitleStrMethod · 0.70
IsTitleWordFunction · 0.70
ToTitleRetFunction · 0.70
to_titleMethod · 0.50

Calls 8

SkipSymbolFunction · 0.85
WriteSymbolFunction · 0.85
ReadSymbolAndAdvanceFunction · 0.85
ToLowerFunction · 0.70
ReadSymbolFunction · 0.70
DetachAndFixPointersFunction · 0.70
sizeMethod · 0.45
dataMethod · 0.45

Tested by 3

TestUnicodeCaseMethod · 0.56
TestWideStringMethod · 0.56
TestToTitleStrMethod · 0.56