diff --git a/src/base/number_util.cc b/src/base/number_util.cc index 5dbf128..45381f1 100644 --- a/src/base/number_util.cc +++ b/src/base/number_util.cc @@ -425,10 +425,10 @@ if (point_pos == StringPiece::npos) { point_pos = input_num.size(); } - const StringPiece integer(input_num, 0, point_pos); + const StringPiece integer = input_num.substr(0, point_pos); // |fraction| has the decimal point with digits in fractional part. - const StringPiece fraction(input_num, point_pos, - input_num.size() - point_pos); + const StringPiece fraction = + input_num.substr(point_pos, input_num.size() - point_pos); // We don't add separator to number whose integral part starts with '0' if (integer[0] == kAsciiZero) { @@ -635,7 +635,7 @@ StringPiece::size_type i; for (i = 0; i < str.size() && isspace(str[i]); ++i) {} DCHECK(i == str.size() || !isspace(str[i])); - return StringPiece(str, i); + return str.substr(i); } // There is an informative discussion about the overflow detection in @@ -826,9 +826,7 @@ } uint64 tmp; if (stripped_str[0] == '-') { - StringPiece opposite_str = StringPiece(stripped_str, - 1, - stripped_str.size() - 1); + StringPiece opposite_str = stripped_str.substr(1, stripped_str.size() - 1); if (!SafeStrToUInt64WithBase(opposite_str, 10, &tmp)) { return false; } diff --git a/src/base/string_piece_test.cc b/src/base/string_piece_test.cc index a738fe0..71d76c0 100644 --- a/src/base/string_piece_test.cc +++ b/src/base/string_piece_test.cc @@ -567,14 +567,14 @@ ASSERT_EQ("12345", StringPiece("12345", 5)); // Tests for StringPiece(const StringPiece, size_type) - ASSERT_EQ("45", StringPiece(StringPiece("12345"), 3)); - ASSERT_EQ("12345", StringPiece(StringPiece("12345"), 0)); - ASSERT_EQ("", StringPiece(StringPiece("12345"), 5)); + ASSERT_EQ("45", StringPiece("12345").substr(3)); + ASSERT_EQ("12345", StringPiece("12345").substr(0)); + ASSERT_EQ("", StringPiece("12345").substr(5)); // Tests for StringPiece(const StringPiece, size_type, size_type) - ASSERT_EQ("234", StringPiece("12345", 1, 3)); - ASSERT_EQ("2345", StringPiece("12345", 1, 300)); - ASSERT_EQ("", StringPiece("12345", 1, 0)); + ASSERT_EQ("234", StringPiece("12345").substr(1, 3)); + ASSERT_EQ("2345", StringPiece("12345").substr(1, 300)); + ASSERT_EQ("", StringPiece("12345").substr(1, 0)); } } // namespace mozc diff --git a/src/data/version/mozc_version_template.bzl b/src/data/version/mozc_version_template.bzl index d432fc7..1836225 100644 --- a/src/data/version/mozc_version_template.bzl +++ b/src/data/version/mozc_version_template.bzl @@ -1,6 +1,6 @@ MAJOR=2 MINOR=18 -BUILD=2562 +BUILD=2563 REVISION=102 # CAUTION: NACL_DICTIONARY_VERSION is going to be migrated to ENGINE_VERSION. # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be diff --git a/src/data_manager/dataset_reader.cc b/src/data_manager/dataset_reader.cc index 690a375..04cc0ea 100644 --- a/src/data_manager/dataset_reader.cc +++ b/src/data_manager/dataset_reader.cc @@ -103,7 +103,8 @@ // Open metadata. DataSetMetadata metadata; - const StringPiece metadata_chunk(memblock, metadata_offset, metadata_size); + const StringPiece metadata_chunk = + memblock.substr(metadata_offset, metadata_size); if (!metadata.ParseFromArray(metadata_chunk.data(), metadata_chunk.size())) { LOG(ERROR) << "Broken: Failed to parse metadata"; return false; diff --git a/src/dictionary/system/system_dictionary.cc b/src/dictionary/system/system_dictionary.cc index 4164e6a..9142964 100644 --- a/src/dictionary/system/system_dictionary.cc +++ b/src/dictionary/system/system_dictionary.cc @@ -732,10 +732,9 @@ // encoded_actual_key_prediction_suffix = encode("ぐる") const StringPiece encoded_actual_key = key_trie_.RestoreKeyString(state.node, encoded_actual_key_buffer); - const StringPiece encoded_actual_key_prediction_suffix( - encoded_actual_key, - encoded_key.size(), - encoded_actual_key.size() - encoded_key.size()); + const StringPiece encoded_actual_key_prediction_suffix = + encoded_actual_key.substr( + encoded_key.size(), encoded_actual_key.size() - encoded_key.size()); // decoded_key = "くーぐる" (= key + prediction suffix) decoded_key.clear(); @@ -828,7 +827,7 @@ if (!key_trie.IsTerminalNode(node)) { continue; } - const StringPiece encoded_prefix(encoded_key, 0, i); + const StringPiece encoded_prefix = encoded_key.substr(0, i); const StringPiece prefix(key, codec->GetDecodedKeyLength(encoded_prefix)); switch (callback->OnKey(prefix)) { @@ -935,7 +934,7 @@ break; } - const StringPiece encoded_prefix(encoded_key, 0, key_pos); + const StringPiece encoded_prefix = encoded_key.substr(0, key_pos); const StringPiece prefix(key, codec_->GetDecodedKeyLength(encoded_prefix)); Callback::ResultType result = callback->OnKey(prefix); if (result == Callback::TRAVERSE_DONE || @@ -1097,7 +1096,7 @@ string lookup_key; lookup_key.reserve(str.size()); while (pos < str.size()) { - const StringPiece suffix(str, pos); + const StringPiece suffix = str.substr(pos); lookup_key.clear(); codec_->EncodeValue(suffix, &lookup_key); AddKeyIdsOfAllPrefixes(value_trie_, lookup_key, &id_set); diff --git a/src/dictionary/user_dictionary.cc b/src/dictionary/user_dictionary.cc index c7bdc5a..e9c9524 100644 --- a/src/dictionary/user_dictionary.cc +++ b/src/dictionary/user_dictionary.cc @@ -70,11 +70,11 @@ struct OrderByKeyPrefix { bool operator()(const UserPOS::Token *token, StringPiece prefix) const { - return StringPiece(token->key, 0, prefix.size()) < prefix; + return StringPiece(token->key).substr(0, prefix.size()) < prefix; } bool operator()(StringPiece prefix, const UserPOS::Token *token) const { - return prefix < StringPiece(token->key, 0, prefix.size()); + return prefix < StringPiece(token->key).substr(0, prefix.size()); } }; @@ -401,7 +401,7 @@ } // Find the starting point for iteration over dictionary contents. - const StringPiece first_char(key, 0, Util::OneCharLen(key.data())); + const StringPiece first_char = key.substr(0, Util::OneCharLen(key.data())); Token token; for (auto it = std::lower_bound(tokens_->begin(), tokens_->end(), first_char, OrderByKey()); diff --git a/src/prediction/dictionary_predictor.cc b/src/prediction/dictionary_predictor.cc index c84406b..a6ff69e 100644 --- a/src/prediction/dictionary_predictor.cc +++ b/src/prediction/dictionary_predictor.cc @@ -182,7 +182,7 @@ // to get more performance but it's overkill here. // TODO(noriyukit): vector would be better than set. To // this end, we need to fix Comopser as well. - const StringPiece rest(key, original_key_len_); + const StringPiece rest = key.substr(original_key_len_); for (const string &chr : *subsequent_chars_) { if (Util::StartsWith(rest, chr)) { return TRAVERSE_CONTINUE;