Skip to content

Commit 8d25d90

Browse files
address comments
1 parent d9db3ac commit 8d25d90

File tree

10 files changed

+20
-18
lines changed

10 files changed

+20
-18
lines changed

libc/src/__support/ctype_utils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ namespace internal {
2626
// functions, make sure you have benchmarks to show your new solution is faster,
2727
// as well as a way to support non-ASCII character encodings.
2828

29+
// Similarly, do not change these functions to use case ranges. e.g.
30+
// bool islower(int ch) {
31+
// switch(ch) {
32+
// case 'a'...'z':
33+
// return true;
34+
// }
35+
// }
36+
// This assumes the character ranges are contiguous, which they aren't in
37+
// EBCDIC. Technically we could use some smaller ranges, but that's even harder
38+
// to read.
39+
2940
LIBC_INLINE static constexpr bool islower(int ch) {
3041
switch (ch) {
3142
case 'a':

libc/src/stdio/printf_core/float_hex_converter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ LIBC_INLINE int convert_float_hex_exp(Writer *writer,
137137
for (; mant_cur > 0; --mant_cur, mantissa >>= 4) {
138138
char mant_mod_16 = static_cast<char>(mantissa % 16);
139139
char new_digit = static_cast<char>(internal::int_to_b36_char(mant_mod_16));
140-
if (internal::isupper(to_conv.conv_name)) {
140+
if (internal::isupper(to_conv.conv_name))
141141
new_digit = static_cast<char>(internal::toupper(new_digit));
142-
}
143142
mant_buffer[mant_cur - 1] = new_digit;
144143
if (new_digit != '0' && first_non_zero < mant_cur)
145144
first_non_zero = mant_cur;

libc/test/src/ctype/isalnum_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ constexpr char ALNUM_ARRAY[] = {
3232
};
3333

3434
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
35-
for (size_t i = 0; i < arr.size(); ++i) {
35+
for (size_t i = 0; i < arr.size(); ++i)
3636
if (static_cast<int>(arr[i]) == ch)
3737
return true;
38-
}
3938
return false;
4039
}
4140

libc/test/src/ctype/isalpha_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ constexpr char ALPHA_ARRAY[] = {
3131
};
3232

3333
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
34-
for (size_t i = 0; i < arr.size(); ++i) {
34+
for (size_t i = 0; i < arr.size(); ++i)
3535
if (static_cast<int>(arr[i]) == ch)
3636
return true;
37-
}
3837
return false;
3938
}
4039

libc/test/src/ctype/isdigit_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ constexpr char DIGIT_ARRAY[] = {
2828
};
2929

3030
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
31-
for (size_t i = 0; i < arr.size(); ++i) {
31+
for (size_t i = 0; i < arr.size(); ++i)
3232
if (static_cast<int>(arr[i]) == ch)
3333
return true;
34-
}
3534
return false;
3635
}
3736

libc/test/src/ctype/islower_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ constexpr char LOWER_ARRAY[] = {
2929
};
3030

3131
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
32-
for (size_t i = 0; i < arr.size(); ++i) {
32+
for (size_t i = 0; i < arr.size(); ++i)
3333
if (static_cast<int>(arr[i]) == ch)
3434
return true;
35-
}
3635
return false;
3736
}
3837

libc/test/src/ctype/isupper_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ constexpr char UPPER_ARRAY[] = {
2929
};
3030

3131
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
32-
for (size_t i = 0; i < arr.size(); ++i) {
32+
for (size_t i = 0; i < arr.size(); ++i)
3333
if (static_cast<int>(arr[i]) == ch)
3434
return true;
35-
}
3635
return false;
3736
}
3837

libc/test/src/ctype/isxdigit_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ constexpr char XDIGIT_ARRAY[] = {
3030
};
3131

3232
bool in_span(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
33-
for (size_t i = 0; i < arr.size(); ++i) {
33+
for (size_t i = 0; i < arr.size(); ++i)
3434
if (static_cast<int>(arr[i]) == ch)
3535
return true;
36-
}
3736
return false;
3837
}
3938

libc/test/src/ctype/tolower_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ static_assert(
3939
"There must be the same number of uppercase and lowercase letters.");
4040

4141
int span_index(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
42-
for (size_t i = 0; i < arr.size(); ++i) {
42+
for (size_t i = 0; i < arr.size(); ++i)
4343
if (static_cast<int>(arr[i]) == ch)
4444
return static_cast<int>(i);
45-
}
4645
return -1;
4746
}
4847

libc/test/src/ctype/toupper_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ static_assert(
3939
"There must be the same number of uppercase and lowercase letters.");
4040

4141
int span_index(int ch, LIBC_NAMESPACE::cpp::span<const char> arr) {
42-
for (size_t i = 0; i < arr.size(); ++i) {
42+
for (size_t i = 0; i < arr.size(); ++i)
4343
if (static_cast<int>(arr[i]) == ch)
4444
return static_cast<int>(i);
45-
}
4645
return -1;
4746
}
4847

0 commit comments

Comments
 (0)