/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// this is faster than calling push_back repeatedly.
while (p != str.end()) {
char c = *p;
- unsigned char v = static_cast<unsigned char>(v);
switch (c) {
case '%':
{
ignoreEmpty);
}
- int tokenStartPos = 0;
- int tokenSize = 0;
- for (int i = 0; i <= strSize - dSize; ++i) {
+ size_t tokenStartPos = 0;
+ size_t tokenSize = 0;
+ for (size_t i = 0; i <= strSize - dSize; ++i) {
if (atDelim(&s[i], delim)) {
if (!ignoreEmpty || tokenSize > 0) {
*out++ = conv(StringPiece(&s[tokenStartPos], tokenSize));
++tokenSize;
}
}
-
+ tokenSize = strSize - tokenStartPos;
if (!ignoreEmpty || tokenSize > 0) {
- tokenSize = strSize - tokenStartPos;
*out++ = conv(StringPiece(&s[tokenStartPos], tokenSize));
}
}
template <class String1, class String2>
void humanify(const String1& input, String2& output) {
- int numUnprintable = 0;
- int numPrintablePrefix = 0;
+ size_t numUnprintable = 0;
+ size_t numPrintablePrefix = 0;
for (unsigned char c : input) {
if (c < 0x20 || c > 0x7e || c == '\\') {
++numUnprintable;
if (!append_output) output.clear();
static char hexValues[] = "0123456789abcdef";
- int j = output.size();
+ auto j = output.size();
output.resize(2 * input.size() + output.size());
- for (int i = 0; i < input.size(); ++i) {
+ for (size_t i = 0; i < input.size(); ++i) {
int ch = input[i];
output[j++] = hexValues[(ch >> 4) & 0xf];
output[j++] = hexValues[ch & 0xf];
-1;
};
- for (int i = 0; i < input.size(); i += 2) {
+ for (size_t i = 0; i < input.size(); i += 2) {
int highBits = unhex(input[i]);
int lowBits = unhex(input[i + 1]);
if (highBits < 0 || lowBits < 0) {