Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1183)

Unified Diff: base/strings/string_util.cc

Issue 1499423004: Remove kint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint9
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/strings/string_util.cc
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index 731a77ddd7697a9c409dd73d277d85aaac89f070..3ca469e0102e1434d31c18a1218f31d639d9d558 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -8,6 +8,7 @@
#include <errno.h>
#include <math.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,9 +17,9 @@
#include <wctype.h>
#include <algorithm>
+#include <limits>
#include <vector>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/strings/string_split.h"
@@ -354,10 +355,11 @@ void TruncateUTF8ToByteSize(const std::string& input,
*output = input;
return;
}
- DCHECK_LE(byte_size, static_cast<uint32>(kint32max));
- // Note: This cast is necessary because CBU8_NEXT uses int32s.
- int32 truncation_length = static_cast<int32>(byte_size);
- int32 char_index = truncation_length - 1;
+ DCHECK_LE(byte_size,
+ static_cast<uint32_t>(std::numeric_limits<int32_t>::max()));
+ // Note: This cast is necessary because CBU8_NEXT uses int32_ts.
+ int32_t truncation_length = static_cast<int32_t>(byte_size);
+ int32_t char_index = truncation_length - 1;
const char* data = input.data();
// Using CBU8, we will move backwards from the truncation point
@@ -365,7 +367,7 @@ void TruncateUTF8ToByteSize(const std::string& input,
// character. Once a full UTF8 character is found, we will
// truncate the string to the end of that character.
while (char_index >= 0) {
- int32 prev = char_index;
+ int32_t prev = char_index;
base_icu::UChar32 code_point = 0;
CBU8_NEXT(data, char_index, truncation_length, code_point);
if (!IsValidCharacter(code_point) ||
@@ -523,11 +525,11 @@ bool IsStringASCII(const std::wstring& str) {
bool IsStringUTF8(const StringPiece& str) {
const char *src = str.data();
- int32 src_len = static_cast<int32>(str.length());
- int32 char_index = 0;
+ int32_t src_len = static_cast<int32_t>(str.length());
+ int32_t char_index = 0;
while (char_index < src_len) {
- int32 code_point;
+ int32_t code_point;
CBU8_NEXT(src, char_index, src_len, code_point);
if (!IsValidCharacter(code_point))
return false;
@@ -680,7 +682,7 @@ static const char* const kByteStringsUnlocalized[] = {
" PB"
};
-string16 FormatBytesUnlocalized(int64 bytes) {
+string16 FormatBytesUnlocalized(int64_t bytes) {
double unit_amount = static_cast<double>(bytes);
size_t dimension = 0;
const int kKilo = 1024;

Powered by Google App Engine
This is Rietveld 408576698