Rename block_bind_incremental to block_bind_referenced
block_bind_incremental is block_bind_referenced in a loop backwards. For an 1-inst block, it does the same thing and isn't too much more expensive, so it's not really useful to keep both. Also, block_bind_referenced was a better name for the function.
This commit is contained in:
1 parent
8537b93a43
commit
260879a5c3
3 files changed
+8
-18
No files matched your search
+1
-1
@@ -1793,7 +1793,7 @@ int builtins_bind(jq_state *jq, block* bb) {
|
||||
builtins = gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), builtins);
|
||||
builtins = gen_builtin_list(builtins);
|
||||
|
||||
*bb = block_bind_incremental(builtins, *bb, OP_IS_CALL_PSEUDO);
|
||||
*bb = block_bind_referenced(builtins, *bb, OP_IS_CALL_PSEUDO);
|
||||
*bb = block_drop_unreferenced(*bb);
|
||||
return nerrors;
|
||||
}
|
||||
+7
-16
@@ -421,20 +421,6 @@ block block_bind_library(block binder, block body, int bindflags, const char *li
|
||||
return body; // We don't return a join because we don't want those sticking around...
|
||||
}
|
||||
|
||||
// Bind binder to body, then throw it away if not referenced.
|
||||
block block_bind_referenced(block binder, block body, int bindflags) {
|
||||
assert(block_is_single(binder));
|
||||
assert(block_has_only_binders(binder, bindflags));
|
||||
bindflags |= OP_HAS_BINDING;
|
||||
|
||||
if (block_bind_subblock(binder, body, bindflags, 0) == 0) {
|
||||
block_free(binder);
|
||||
} else {
|
||||
body = BLOCK(binder, body);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
static inst* block_take_last(block* b) {
|
||||
inst* i = b->last;
|
||||
if (i == 0)
|
||||
@@ -452,13 +438,18 @@ static inst* block_take_last(block* b) {
|
||||
|
||||
// Binds a sequence of binders, which *must not* alrady be bound to each other,
|
||||
// to body, throwing away unreferenced defs
|
||||
block block_bind_incremental(block binder, block body, int bindflags) {
|
||||
block block_bind_referenced(block binder, block body, int bindflags) {
|
||||
assert(block_has_only_binders(binder, bindflags));
|
||||
bindflags |= OP_HAS_BINDING;
|
||||
|
||||
inst* curr;
|
||||
while ((curr = block_take_last(&binder))) {
|
||||
body = block_bind_referenced(inst_block(curr), body, bindflags);
|
||||
block b = inst_block(curr);
|
||||
if (block_bind_subblock(b, body, bindflags, 0) == 0) {
|
||||
block_free(b);
|
||||
} else {
|
||||
body = BLOCK(b, body);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ int block_is_funcdef(block b);
|
||||
int block_is_single(block b);
|
||||
block block_bind_library(block binder, block body, int bindflags, const char* libname);
|
||||
block block_bind_referenced(block binder, block body, int bindflags);
|
||||
block block_bind_incremental(block binder, block body, int bindflags);
|
||||
block block_bind_self(block binder, int bindflags);
|
||||
block block_drop_unreferenced(block body);
|
||||
|
||||
|
||||
Reference in new issue
Block a user