summaryrefslogtreecommitdiff
path: root/yarp/yarp_compiler.c
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2023-09-19 11:35:22 -0400
committerKevin Newton <[email protected]>2023-09-19 15:38:41 -0400
commit3e4ccd6ddc4abbd3f08c628c4e56d54ef00c5bfa (patch)
treee487b5dc71eea99d37defbbb4ffff8b2a3964497 /yarp/yarp_compiler.c
parent7dee7e611661c335321c2bb8e6b4738ab9f7c2fd (diff)
[YARP] Use the static literal flag
Diffstat (limited to 'yarp/yarp_compiler.c')
-rw-r--r--yarp/yarp_compiler.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/yarp/yarp_compiler.c b/yarp/yarp_compiler.c
index fbd9ccbb17..22aecdaa4a 100644
--- a/yarp/yarp_compiler.c
+++ b/yarp/yarp_compiler.c
@@ -141,23 +141,14 @@ yp_optimizable_range_item_p(yp_node_t *node)
return (!node || YP_NODE_TYPE_P(node, YP_INTEGER_NODE) || YP_NODE_TYPE_P(node, YP_NIL_NODE));
}
-static bool
-yp_static_node_literal_p(yp_node_t *node)
-{
- switch (YP_NODE_TYPE(node)) {
- case YP_FALSE_NODE:
- case YP_FLOAT_NODE:
- case YP_IMAGINARY_NODE:
- case YP_INTEGER_NODE:
- case YP_NIL_NODE:
- case YP_RATIONAL_NODE:
- case YP_STRING_NODE:
- case YP_SYMBOL_NODE:
- case YP_TRUE_NODE:
- return true;
- default:
- return false;
- }
+/**
+ * Certain nodes can be compiled literally, which can lead to further
+ * optimizations. These nodes will all have the YP_NODE_FLAG_STATIC_LITERAL flag
+ * set.
+ */
+static inline bool
+yp_static_node_literal_p(yp_node_t *node) {
+ return node->flags & YP_NODE_FLAG_STATIC_LITERAL;
}
static inline VALUE