[ruby/yarp] Separate yp_node_flags_t from yp_node_type_t
Prior to this commit, we folded the flags into the type. This created extra overhead when calculating the type and setting the flags. This commit separates them. https://github.com/ruby/yarp/commit/b783a5678c
This commit is contained in:
parent
89de544442
commit
383c47f538
Notes:
git
2023-08-17 00:48:01 +00:00
19
yarp/yarp.c
19
yarp/yarp.c
@ -505,7 +505,7 @@ yp_statements_node_body_append(yp_statements_node_t *node, yp_node_t *statement)
|
||||
// implement our own arena allocation.
|
||||
static inline void *
|
||||
yp_alloc_node(YP_ATTRIBUTE_UNUSED yp_parser_t *parser, size_t size) {
|
||||
void *memory = malloc(size);
|
||||
void *memory = calloc(1, size);
|
||||
if (memory == NULL) {
|
||||
fprintf(stderr, "Failed to allocate %zu bytes\n", size);
|
||||
abort();
|
||||
@ -2289,7 +2289,8 @@ yp_if_node_create(yp_parser_t *parser,
|
||||
|
||||
*node = (yp_if_node_t) {
|
||||
{
|
||||
.type = YP_NODE_IF_NODE | YP_NODE_FLAG_NEWLINE,
|
||||
.flags = YP_NODE_FLAG_NEWLINE,
|
||||
.type = YP_NODE_IF_NODE,
|
||||
.location = {
|
||||
.start = if_keyword->start,
|
||||
.end = end
|
||||
@ -2315,7 +2316,8 @@ yp_if_node_modifier_create(yp_parser_t *parser, yp_node_t *statement, const yp_t
|
||||
|
||||
*node = (yp_if_node_t) {
|
||||
{
|
||||
.type = YP_NODE_IF_NODE | YP_NODE_FLAG_NEWLINE,
|
||||
.flags = YP_NODE_FLAG_NEWLINE,
|
||||
.type = YP_NODE_IF_NODE,
|
||||
.location = {
|
||||
.start = statement->location.start,
|
||||
.end = predicate->location.end
|
||||
@ -2347,7 +2349,8 @@ yp_if_node_ternary_create(yp_parser_t *parser, yp_node_t *predicate, yp_node_t *
|
||||
|
||||
*node = (yp_if_node_t) {
|
||||
{
|
||||
.type = YP_NODE_IF_NODE | YP_NODE_FLAG_NEWLINE,
|
||||
.flags = YP_NODE_FLAG_NEWLINE,
|
||||
.type = YP_NODE_IF_NODE,
|
||||
.location = {
|
||||
.start = predicate->location.start,
|
||||
.end = false_expression->location.end,
|
||||
@ -3751,7 +3754,7 @@ yp_statements_node_body_append(yp_statements_node_t *node, yp_node_t *statement)
|
||||
node->base.location.end = statement->location.end;
|
||||
|
||||
// Every statement gets marked as a place where a newline can occur.
|
||||
statement->type |= YP_NODE_FLAG_NEWLINE;
|
||||
statement->flags = YP_NODE_FLAG_NEWLINE;
|
||||
}
|
||||
|
||||
// Allocate a new StringConcatNode node.
|
||||
@ -3982,7 +3985,8 @@ yp_unless_node_create(yp_parser_t *parser, const yp_token_t *keyword, yp_node_t
|
||||
|
||||
*node = (yp_unless_node_t) {
|
||||
{
|
||||
.type = YP_NODE_UNLESS_NODE | YP_NODE_FLAG_NEWLINE,
|
||||
.flags = YP_NODE_FLAG_NEWLINE,
|
||||
.type = YP_NODE_UNLESS_NODE,
|
||||
.location = {
|
||||
.start = keyword->start,
|
||||
.end = end
|
||||
@ -4008,7 +4012,8 @@ yp_unless_node_modifier_create(yp_parser_t *parser, yp_node_t *statement, const
|
||||
|
||||
*node = (yp_unless_node_t) {
|
||||
{
|
||||
.type = YP_NODE_UNLESS_NODE | YP_NODE_FLAG_NEWLINE,
|
||||
.flags = YP_NODE_FLAG_NEWLINE,
|
||||
.type = YP_NODE_UNLESS_NODE,
|
||||
.location = {
|
||||
.start = statement->location.start,
|
||||
.end = predicate->location.end
|
||||
|
Loading…
x
Reference in New Issue
Block a user