Bug 1233101 - Use MOZ_LIKELY in js_new etc to help branch prediction; r=terrence

This commit is contained in:
Nick Fitzgerald 2015-12-18 12:05:14 -08:00
parent e56f1b5f60
commit bde15e81a7

View File

@ -302,12 +302,12 @@ static inline char* js_strdup(const char* s)
* Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS,
* or the build will break.
*/
#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS)\
#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \
template <class T, typename... Args> \
QUALIFIERS T * \
NEWNAME(Args&&... args) MOZ_HEAP_ALLOCATOR { \
void* memory = ALLOCATOR(sizeof(T)); \
return memory \
return MOZ_LIKELY(memory) \
? new(memory) T(mozilla::Forward<Args>(args)...) \
: nullptr; \
}