summaryrefslogtreecommitdiff
path: root/libutils/String8.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-04-08 13:26:49 -0700
committerElliott Hughes <enh@google.com>2021-04-09 13:06:20 -0700
commita858395f91d09ddedfaab4f3094000ac32f3d124 (patch)
treed7117bdc107c55f024a8046388d9df4ae9d2d294 /libutils/String8.cpp
parent05a7dfa104c8eb7e2c4f0485ecc187ad6e93bb0d (diff)
Remove the weird range variants of String8::toLower() and String8::toUpper().
I want to remove these bad ASCII-only APIs completely, but it might be easier to remove the range variants first. Test: treehugger Change-Id: I4c11f959a7bd8e670708cc03281ea72e9c461ff7
Diffstat (limited to 'libutils/String8.cpp')
-rw-r--r--libutils/String8.cpp42
1 files changed, 10 insertions, 32 deletions
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 3dc2026d9..fad130b1b 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -415,50 +415,28 @@ bool String8::removeAll(const char* other) {
void String8::toLower()
{
- toLower(0, size());
-}
+ const size_t length = size();
+ if (length == 0) return;
-void String8::toLower(size_t start, size_t length)
-{
- const size_t len = size();
- if (start >= len) {
- return;
- }
- if (start+length > len) {
- length = len-start;
- }
- char* buf = lockBuffer(len);
- buf += start;
- while (length > 0) {
+ char* buf = lockBuffer(length);
+ for (size_t i = length; i > 0; --i) {
*buf = static_cast<char>(tolower(*buf));
buf++;
- length--;
}
- unlockBuffer(len);
+ unlockBuffer(length);
}
void String8::toUpper()
{
- toUpper(0, size());
-}
+ const size_t length = size();
+ if (length == 0) return;
-void String8::toUpper(size_t start, size_t length)
-{
- const size_t len = size();
- if (start >= len) {
- return;
- }
- if (start+length > len) {
- length = len-start;
- }
- char* buf = lockBuffer(len);
- buf += start;
- while (length > 0) {
+ char* buf = lockBuffer(length);
+ for (size_t i = length; i > 0; --i) {
*buf = static_cast<char>(toupper(*buf));
buf++;
- length--;
}
- unlockBuffer(len);
+ unlockBuffer(length);
}
// ---------------------------------------------------------------------------