diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-27 06:16:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-27 06:16:16 +0000 |
commit | fc9fffca1d4f44d740a726db00d9ef3c9cca1312 (patch) | |
tree | bdd8ab9566d7fa1be365dc47f78282ddca74b47a /symbol.h | |
parent | ce9fc203d1e7cd97d68fab6e10733bd62f065c5a (diff) | |
download | bundler-fc9fffca1d4f44d740a726db00d9ef3c9cca1312.tar.gz |
symbol.h: optimize ID2SYM
* symbol.h (rb_id2sym): optimize for predefined IDs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.h')
-rw-r--r-- | symbol.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -14,6 +14,15 @@ #include "id.h" +#define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID) +#define STATIC_ID2SYM(id) (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG) + +#ifdef __GNUC__ +#define rb_id2sym(id) \ + __extension__(__builtin_constant_p(id) && !DYNAMIC_ID_P(id) ? \ + STATIC_ID2SYM(id) : rb_id2sym(id)) +#endif + struct RSymbol { struct RBasic basic; VALUE fstr; |