Skip to content

Commit 39770bc

Browse files
committed
Convert macros to inline functions in Zend SmartStr
1 parent 413f4b6 commit 39770bc

File tree

1 file changed

+49
-23
lines changed

1 file changed

+49
-23
lines changed

Zend/zend_smart_str.h

+49-23
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@
2121
#include "zend_globals.h"
2222
#include "zend_smart_str_public.h"
2323

24-
#define smart_str_appends_ex(dest, src, what) \
25-
smart_str_appendl_ex((dest), (src), strlen(src), (what))
26-
#define smart_str_appends(dest, src) \
27-
smart_str_appendl((dest), (src), strlen(src))
28-
#define smart_str_extend(dest, len) \
29-
smart_str_extend_ex((dest), (len), 0)
30-
#define smart_str_appendc(dest, c) \
31-
smart_str_appendc_ex((dest), (c), 0)
32-
#define smart_str_appendl(dest, src, len) \
33-
smart_str_appendl_ex((dest), (src), (len), 0)
34-
#define smart_str_append(dest, src) \
35-
smart_str_append_ex((dest), (src), 0)
36-
#define smart_str_append_smart_str(dest, src) \
37-
smart_str_append_smart_str_ex((dest), (src), 0)
38-
#define smart_str_sets(dest, src) \
39-
smart_str_setl((dest), (src), strlen(src));
40-
#define smart_str_append_long(dest, val) \
41-
smart_str_append_long_ex((dest), (val), 0)
42-
#define smart_str_append_unsigned(dest, val) \
43-
smart_str_append_unsigned_ex((dest), (val), 0)
44-
#define smart_str_free(dest) \
45-
smart_str_free_ex((dest), 0)
46-
4724
BEGIN_EXTERN_C()
4825

4926
ZEND_API void ZEND_FASTCALL smart_str_erealloc(smart_str *str, size_t len);
@@ -78,6 +55,11 @@ static zend_always_inline char* smart_str_extend_ex(smart_str *dest, size_t len,
7855
return ret;
7956
}
8057

58+
static inline char* smart_str_extend(smart_str *dest, size_t length)
59+
{
60+
return smart_str_extend_ex(dest, length, 0);
61+
}
62+
8163
static zend_always_inline void smart_str_free_ex(smart_str *str, zend_bool persistent) {
8264
if (str->s) {
8365
zend_string_release_ex(str->s, persistent);
@@ -86,6 +68,11 @@ static zend_always_inline void smart_str_free_ex(smart_str *str, zend_bool persi
8668
str->a = 0;
8769
}
8870

71+
static inline void smart_str_free(smart_str *str)
72+
{
73+
smart_str_free_ex(str, 0);
74+
}
75+
8976
static zend_always_inline void smart_str_0(smart_str *str) {
9077
if (str->s) {
9178
ZSTR_VAL(str->s)[ZSTR_LEN(str->s)] = '\0';
@@ -136,15 +123,54 @@ static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_lo
136123
smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
137124
}
138125

126+
static inline void smart_str_append_long(smart_str *dest, zend_long num)
127+
{
128+
smart_str_append_long_ex(dest, num, 0);
129+
}
130+
139131
static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) {
140132
char buf[32];
141133
char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num);
142134
smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
143135
}
144136

137+
static inline void smart_str_append_unsigned(smart_str *dest, zend_ulong num)
138+
{
139+
smart_str_append_unsigned_ex(dest, num, 0);
140+
}
141+
142+
static inline void smart_str_appendl(smart_str *dest, const char *src, size_t length)
143+
{
144+
smart_str_appendl_ex(dest, src, length, 0);
145+
}
146+
static inline void smart_str_appends_ex(smart_str *dest, const char *src, bool persistent)
147+
{
148+
smart_str_appendl_ex(dest, src, strlen(src), persistent);
149+
}
150+
static inline void smart_str_appends(smart_str *dest, const char *src)
151+
{
152+
smart_str_appendl_ex(dest, src, strlen(src), 0);
153+
}
154+
static inline void smart_str_append(smart_str *dest, const zend_string *src)
155+
{
156+
smart_str_append_ex(dest, src, 0);
157+
}
158+
static inline void smart_str_appendc(smart_str *dest, char ch)
159+
{
160+
smart_str_appendc_ex(dest, ch, 0);
161+
}
162+
static inline void smart_str_append_smart_str(smart_str *dest, const smart_str *src)
163+
{
164+
smart_str_append_smart_str_ex(dest, src, 0);
165+
}
166+
145167
static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
146168
smart_str_free(dest);
147169
smart_str_appendl(dest, src, len);
148170
}
149171

172+
static inline void smart_str_sets(smart_str *dest, const char *src)
173+
{
174+
smart_str_setl(dest, src, strlen(src));
175+
}
150176
#endif

0 commit comments

Comments
 (0)