From f181d1efae0010064558efb52d9e152252685ee3 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Fri, 4 Jan 2019 21:07:58 +0000 Subject: [PATCH] Simplify ToCamelCase --- javascript/net/grpc/web/grpc_generator.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/javascript/net/grpc/web/grpc_generator.cc b/javascript/net/grpc/web/grpc_generator.cc index 29b07e71..b07df7a4 100644 --- a/javascript/net/grpc/web/grpc_generator.cc +++ b/javascript/net/grpc/web/grpc_generator.cc @@ -258,18 +258,11 @@ string JSFieldName(const FieldDescriptor *desc) // Like ToUpperCamel except the first letter is not converted. string ToCamelCase(const std::vector& words) { - if words.size() == 0 { - return "" + if (words.size() == 0) { + return ""; } - string result = words[0] - for (size_t i = 1; i < words.size(); i++) { - string word = words[i]; - if (word[0] >= 'a' && word[0] <= 'z') { - word[0] = (word[0] - 'a') + 'A'; - } - result += word; - } - return result; + string result = words[0]; + return result + ToUpperCamel(std::vector(words.begin()+1, words.begin()+words.size())); } // Like JSFieldName, but with first letter not uppercased