[core] inline some buffer.[ch] routines
parent
3eb7902e10
commit
6ebd289788
20
src/buffer.c
20
src/buffer.c
|
@ -940,26 +940,6 @@ void buffer_path_simplify(buffer *dest, buffer *src)
|
|||
buffer_string_set_length(dest, out - start);
|
||||
}
|
||||
|
||||
int light_isdigit(int c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
int light_isxdigit(int c) {
|
||||
if (light_isdigit(c)) return 1;
|
||||
|
||||
c |= 32;
|
||||
return (c >= 'a' && c <= 'f');
|
||||
}
|
||||
|
||||
int light_isalpha(int c) {
|
||||
c |= 32;
|
||||
return (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
int light_isalnum(int c) {
|
||||
return light_isdigit(c) || light_isalpha(c);
|
||||
}
|
||||
|
||||
void buffer_to_lower(buffer *b) {
|
||||
size_t i;
|
||||
|
||||
|
|
25
src/buffer.h
25
src/buffer.h
|
@ -137,10 +137,27 @@ void buffer_to_upper(buffer *b);
|
|||
char hex2int(unsigned char c);
|
||||
char int2hex(char i);
|
||||
|
||||
int light_isdigit(int c);
|
||||
int light_isxdigit(int c);
|
||||
int light_isalpha(int c);
|
||||
int light_isalnum(int c);
|
||||
static inline int light_isdigit(int c);
|
||||
static inline int light_isxdigit(int c);
|
||||
static inline int light_isalpha(int c);
|
||||
static inline int light_isalnum(int c);
|
||||
|
||||
static inline int light_isdigit(int c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
static inline int light_isxdigit(int c) {
|
||||
return light_isdigit(c) || (c |= 32, c >= 'a' && c <= 'f');
|
||||
}
|
||||
|
||||
static inline int light_isalpha(int c) {
|
||||
return (c |= 32, c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
static inline int light_isalnum(int c) {
|
||||
return light_isdigit(c) || light_isalpha(c);
|
||||
}
|
||||
|
||||
|
||||
static inline size_t buffer_string_length(const buffer *b); /* buffer string length without terminating 0 */
|
||||
static inline size_t buffer_string_space(const buffer *b); /* maximum length of string that can be stored without reallocating */
|
||||
|
|
Loading…
Reference in New Issue