Use for-range loop, add comment

This commit is contained in:
Kruglov Pavel 2023-07-27 00:01:25 +02:00 committed by GitHub
parent bc86c26e4e
commit 0cd2d7449b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,11 +35,14 @@ void endNested(WriteBuffer & buf, size_t indent)
String getSchemaFieldName(const String & column_name)
{
String result = column_name;
size_t i = 0;
while (i < result.size() && isupper(result[i]))
/// Replace all first uppercase letters to lower-case,
/// because fields in CapnProto schema must begin with a lower-case letter.
/// Don't replace all letters to lower-case to remain camelCase field names.
for (auto & symbol : result)
{
result[i] = tolower(result[i]);
++i;
if (islower(symbol))
break;
symbol = tolower(symbol);
}
return result;
}