diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 430f4dec02e2..d2b382390009 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -71,33 +71,49 @@ END_EXTERN_C() /*---*/ -#define ZSTR_IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED) -#define ZSTR_IS_VALID_UTF8(s) (GC_FLAGS(s) & IS_STR_VALID_UTF8) +static zend_always_inline bool ZSTR_IS_INTERNED(const zend_string *s) { + return GC_FLAGS(s) & IS_STR_INTERNED; +} + +static inline bool ZSTR_IS_VALID_UTF8(const zend_string *s) { + return GC_FLAGS(s) & IS_STR_VALID_UTF8; +} /* These are properties, encoded as flags, that will hold on the resulting string * after concatenating two strings that have these property. * Example: concatenating two UTF-8 strings yields another UTF-8 string. */ #define ZSTR_COPYABLE_CONCAT_PROPERTIES (IS_STR_VALID_UTF8) -#define ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(s) (GC_FLAGS(s) & ZSTR_COPYABLE_CONCAT_PROPERTIES) -/* This macro returns the copyable concat properties which hold on both strings. */ -#define ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(s1, s2) (GC_FLAGS(s1) & GC_FLAGS(s2) & ZSTR_COPYABLE_CONCAT_PROPERTIES) +static inline uint32_t ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(const zend_string *s) { + return GC_FLAGS(s) & ZSTR_COPYABLE_CONCAT_PROPERTIES; +} -#define ZSTR_COPY_CONCAT_PROPERTIES(out, in) do { \ - zend_string *_out = (out); \ - uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES((in)); \ - GC_ADD_FLAGS(_out, properties); \ -} while (0) +/* This function returns the copyable concat properties which hold on both strings. */ +static inline uint32_t ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(const zend_string *s1, const zend_string *s2) { + return ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(s1) & ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(s2); +} -#define ZSTR_COPY_CONCAT_PROPERTIES_BOTH(out, in1, in2) do { \ - zend_string *_out = (out); \ - uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH((in1), (in2)); \ - GC_ADD_FLAGS(_out, properties); \ -} while (0) +static inline void ZSTR_COPY_CONCAT_PROPERTIES(zend_string *out, const zend_string *in) { + uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES(in); + GC_ADD_FLAGS(out, properties); +} -#define ZSTR_EMPTY_ALLOC() zend_empty_string -#define ZSTR_CHAR(c) zend_one_char_string[c] -#define ZSTR_KNOWN(idx) zend_known_strings[idx] +static inline void ZSTR_COPY_CONCAT_PROPERTIES_BOTH(zend_string *out, const zend_string *in1, const zend_string *in2) { + uint32_t properties = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(in1, in2); + GC_ADD_FLAGS(out, properties); +} + +static zend_always_inline zend_string *ZSTR_EMPTY_ALLOC(void) { + return zend_empty_string; +} + +static zend_always_inline zend_string *ZSTR_CHAR(unsigned char c) { + return zend_one_char_string[c]; +} + +static zend_always_inline zend_string *ZSTR_KNOWN(size_t idx) { + return zend_known_strings[idx]; +} #define _ZSTR_HEADER_SIZE XtOffsetOf(zend_string, val)