summaryrefslogtreecommitdiff
path: root/symbol.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-27 06:16:16 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-27 06:16:16 (GMT)
commitfc9fffca1d4f44d740a726db00d9ef3c9cca1312 (patch)
treebdd8ab9566d7fa1be365dc47f78282ddca74b47a /symbol.h
parentce9fc203d1e7cd97d68fab6e10733bd62f065c5a (diff)
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.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/symbol.h b/symbol.h
index d624a46..3e14e02 100644
--- a/symbol.h
+++ b/symbol.h
@@ -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;