Skip to content

Commit ecdc69c

Browse files
committed
Using OPAL_UNLIKELY for index checking in opal_pointer_array.
1 parent 3c325ca commit ecdc69c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

opal/class/opal_pointer_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int opal_pointer_array_set_item(opal_pointer_array_t *table, int index,
166166
{
167167
assert(table != NULL);
168168

169-
if (0 > index) {
169+
if (OPAL_UNLIKELY(0 > index)) {
170170
return OPAL_ERROR;
171171
}
172172

opal/class/opal_pointer_array.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "opal/threads/mutex.h"
3535
#include "opal/class/opal_object.h"
36+
#include "opal/prefetch.h"
3637

3738
BEGIN_C_DECLS
3839

@@ -124,7 +125,7 @@ static inline void *opal_pointer_array_get_item(opal_pointer_array_t *table,
124125
{
125126
void *p;
126127

127-
if( 0 > element_index || table->size <= element_index ) {
128+
if( OPAL_UNLIKELY(0 > element_index || table->size <= element_index) ) {
128129
return NULL;
129130
}
130131
OPAL_THREAD_LOCK(&(table->lock));

0 commit comments

Comments
 (0)