Skip to content

Commit 62bfb01

Browse files
committed
refactor: zend_call_stack_get_linux_pthread
GCC doesn't pessimize the error cases correctly: https://godbolt.org/z/Pa6xsKMWc This speeds up the happy case and in this case the code size is also smaller, so it's a double-win.
1 parent 550f840 commit 62bfb01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Zend/zend_call_stack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
133133
ZEND_ASSERT(!zend_call_stack_is_main_thread());
134134

135135
error = pthread_getattr_np(pthread_self(), &attr);
136-
if (error) {
136+
if (UNEXPECTED(error)) {
137137
return false;
138138
}
139139

140140
error = pthread_attr_getstack(&attr, &addr, &max_size);
141-
if (error) {
141+
if (UNEXPECTED(error)) {
142142
pthread_attr_destroy(&attr);
143143
return false;
144144
}
@@ -148,7 +148,7 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
148148
size_t guard_size;
149149
/* In glibc prior to 2.8, addr and size include the guard pages */
150150
error = pthread_attr_getguardsize(&attr, &guard_size);
151-
if (error) {
151+
if (UNEXPECTED(error)) {
152152
pthread_attr_destroy(&attr);
153153
return false;
154154
}

0 commit comments

Comments
 (0)