Skip to content

Commit 60eca49

Browse files
authored
Avoid copying cppy::ptrs in safe_richcompare (#239)
* Avoid copying cppy::ptrs in safe_richcompare * Add comment on passing by reference
1 parent 338630c commit 60eca49

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

atom/src/utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ inline bool safe_richcompare( PyObject* first, PyObject* second, int opid )
129129
return false;
130130
}
131131

132-
inline bool safe_richcompare( cppy::ptr first, PyObject* second, int opid )
132+
inline bool safe_richcompare( const cppy::ptr &first, PyObject* second, int opid )
133133
{
134134
return safe_richcompare( first.get(), second, opid );
135135
}
136136

137137

138-
inline bool safe_richcompare( PyObject* first, cppy::ptr second, int opid )
138+
inline bool safe_richcompare( PyObject* first, const cppy::ptr &second, int opid )
139139
{
140140
return safe_richcompare( first, second.get(), opid );
141141
}
142142

143-
144-
inline bool safe_richcompare( cppy::ptr first, cppy::ptr second, int opid )
143+
// Passing by reference avoids an extra incref/decref pair
144+
inline bool safe_richcompare( const cppy::ptr &first, const cppy::ptr &second, int opid )
145145
{
146146
return safe_richcompare( first.get(), second.get(), opid );
147147
}

0 commit comments

Comments
 (0)