Skip to content

Commit

Permalink
Performance optimisation in assert, suggested by Tim Bunce
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rgs committed Nov 15, 2009
1 parent 689e417 commit d0f83c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scope.h
Expand Up @@ -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
Expand Down

0 comments on commit d0f83c3

Please sign in to comment.