@@ -54,7 +54,7 @@ int stricmp(const char* s1, const char* s2);
5454 * @param n Number of characters to compare
5555 * @return int Comparison result as with strcmp()
5656 */
57- int strncmp (const char * s1 , const char * s2 , uint32_t n );
57+ __attribute__(( hot )) int strncmp (const char * s1 , const char * s2 , uint32_t n );
5858
5959/**
6060 * @brief Compare first n characters of two strings (case-insensitive).
@@ -72,47 +72,75 @@ int strnicmp(const char* s1, const char* s2, uint32_t n);
7272 * @param low Character to convert
7373 * @return char Uppercase equivalent if alphabetic, otherwise unchanged
7474 */
75- char toupper (char low );
75+ static inline char __attribute__((always_inline )) toupper (char low ) {
76+ return low >= 'a' && low <= 'z' ? low - 32 : low ;
77+ }
7678
7779/**
7880 * @brief Check if a character is uppercase.
7981 *
8082 * @param x Character to check
8183 * @return int Non-zero if uppercase, 0 otherwise
8284 */
83- int isupper (const char x );
85+ static inline int __attribute__((always_inline )) isupper (const char x )
86+ {
87+ return (unsigned )(x - 'A' ) <= ('Z' - 'A' );
88+ }
8489
8590/**
8691 * @brief Convert a character to lowercase.
8792 *
8893 * @param low Character to convert
8994 * @return char Lowercase equivalent if alphabetic, otherwise unchanged
9095 */
91- char tolower (char low );
96+ static inline char __attribute__((always_inline )) tolower (char low ) {
97+ return low >= 'A' && low <= 'Z' ? low + 32 : low ;
98+ }
99+
92100
93101/**
94- * @brief Check if a character is alphanumeric .
102+ * @brief Check if a character is alphabetic .
95103 *
96104 * @param x Character to check
97- * @return int Non-zero if alphanumeric, 0 otherwise
105+ * @return bool true if alphabetic, false otherwise
98106 */
99- int isalnum (const char x );
107+ static inline bool __attribute__((always_inline )) isalpha (const char x )
108+ {
109+ unsigned char c = (unsigned char )(x | 0x20 );
110+ return (unsigned )(c - 'a' ) <= ('z' - 'a' );
111+ }
112+
113+ static inline unsigned char __attribute__((always_inline )) isdigit (const char x )
114+ {
115+ return (unsigned )(x - '0' ) <= 9 ;
116+ }
117+
118+ static inline unsigned char __attribute__((always_inline )) isxdigit (const char x )
119+ {
120+ return (x >= '0' && x <= '9' ) || (x >= 'A' && x <= 'F' );
121+ }
100122
101123/**
102- * @brief Check if a character is whitespace .
124+ * @brief Check if a character is alphanumeric .
103125 *
104126 * @param x Character to check
105- * @return bool true if whitespace, false otherwise
127+ * @return int Non-zero if alphanumeric, 0 otherwise
106128 */
107- bool isspace (const char x );
129+ static inline int __attribute__((always_inline )) isalnum (const char x )
130+ {
131+ return isdigit (x ) || isalpha (x );
132+ }
108133
109134/**
110- * @brief Check if a character is alphabetic .
135+ * @brief Check if a character is whitespace .
111136 *
112137 * @param x Character to check
113- * @return bool true if alphabetic , false otherwise
138+ * @return bool true if whitespace , false otherwise
114139 */
115- bool isalpha (const char x );
140+ static inline bool __attribute__((always_inline )) isspace (const char x )
141+ {
142+ return x == ' ' || x == '\t' ;
143+ }
116144
117145/**
118146 * @brief Locate first occurrence of a character in a string.
@@ -228,7 +256,7 @@ int atoi(const char *s);
228256 * @param radix Base (e.g. 10 for decimal, 16 for hex)
229257 * @return int64_t Converted value
230258 */
231- int64_t atoll (const char * s , int radix );
259+ __attribute__(( hot )) int64_t atoll (const char * s , int radix );
232260
233261/**
234262 * @brief Convert string to 64-bit unsigned integer.
0 commit comments