Skip to content

Commit

Permalink
Mark inline functions with only a simple comparison in strings/ascii.…
Browse files Browse the repository at this point in the history
…h as constexpr.

PiperOrigin-RevId: 686814718
Change-Id: Ia712f4cd24ebf3d02fd0b03cd6973bb53e128682
  • Loading branch information
Abseil Team authored and copybara-github committed Oct 17, 2024
1 parent 202a8f4 commit 8c495b5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions absl/strings/ascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,42 @@ inline bool ascii_isxdigit(unsigned char c) {
//
// Determines whether the given character can be represented as a decimal
// digit character (i.e. {0-9}).
inline bool ascii_isdigit(unsigned char c) { return c >= '0' && c <= '9'; }
inline constexpr bool ascii_isdigit(unsigned char c) {
return c >= '0' && c <= '9';
}

// ascii_isprint()
//
// Determines whether the given character is printable, including spaces.
inline bool ascii_isprint(unsigned char c) { return c >= 32 && c < 127; }
inline constexpr bool ascii_isprint(unsigned char c) {
return c >= 32 && c < 127;
}

// ascii_isgraph()
//
// Determines whether the given character has a graphical representation.
inline bool ascii_isgraph(unsigned char c) { return c > 32 && c < 127; }
inline constexpr bool ascii_isgraph(unsigned char c) {
return c > 32 && c < 127;
}

// ascii_isupper()
//
// Determines whether the given character is uppercase.
inline bool ascii_isupper(unsigned char c) { return c >= 'A' && c <= 'Z'; }
inline constexpr bool ascii_isupper(unsigned char c) {
return c >= 'A' && c <= 'Z';
}

// ascii_islower()
//
// Determines whether the given character is lowercase.
inline bool ascii_islower(unsigned char c) { return c >= 'a' && c <= 'z'; }
inline constexpr bool ascii_islower(unsigned char c) {
return c >= 'a' && c <= 'z';
}

// ascii_isascii()
//
// Determines whether the given character is ASCII.
inline bool ascii_isascii(unsigned char c) { return c < 128; }
inline constexpr bool ascii_isascii(unsigned char c) { return c < 128; }

// ascii_tolower()
//
Expand Down

0 comments on commit 8c495b5

Please sign in to comment.