Skip to content

Commit 8a720ce

Browse files
Inline single-use ns_index_base_name (closes #217)
1 parent 3bf8519 commit 8a720ce

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/ns_buffer.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,20 +430,13 @@ bool ns_buffer_assign(struct Env *env, const char *name, Value value, DeclType t
430430
return r;
431431
}
432432

433-
static const char *ns_index_base_name(Expr *idx_expr) {
434-
Expr *walker = idx_expr;
435-
while (walker && walker->type == EXPR_INDEX) {
436-
walker = walker->as.index.target;
437-
}
438-
if (!walker || walker->type != EXPR_IDENT) {
439-
return NULL;
440-
}
441-
return walker->as.ident;
442-
}
443-
444433
bool ns_buffer_assign_index(struct Interpreter *interp, struct Env *env, Expr *idx_expr, Value value, int stmt_line,
445434
int stmt_col, char **out_error, int *out_line, int *out_col) {
446-
const char *base_name = ns_index_base_name(idx_expr);
435+
Expr *base_walker = idx_expr;
436+
while (base_walker && base_walker->type == EXPR_INDEX) {
437+
base_walker = base_walker->as.index.target;
438+
}
439+
const char *base_name = (!base_walker || base_walker->type != EXPR_IDENT) ? NULL : base_walker->as.ident;
447440
if (out_error) {
448441
*out_error = NULL;
449442
}

0 commit comments

Comments
 (0)