From d0f83c37b9d28134de63d7e3eb8427ccf56ca5ba Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Sun, 15 Nov 2009 01:34:03 +0100 Subject: [PATCH] Performance optimisation in assert, suggested by Tim Bunce Most compilers will store only a single copy of identical literal strings. So changing that assert to check the pointer first would significantly reduce the cost. --- scope.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scope.h b/scope.h index 9fd3bce578e7..2f50398eabb9 100644 --- a/scope.h +++ b/scope.h @@ -140,7 +140,9 @@ scope has the given name. Name must be a literal string. #define LEAVE_with_name(name) \ STMT_START { \ DEBUG_SCOPE("LEAVE \"" name "\"") \ - assert(strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \ + assert(((char*)PL_scopestack_name[PL_scopestack_ix-1] \ + == (char*)name) \ + || strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \ pop_scope(); \ } STMT_END #else