Skip to content

Commit 39b2d44

Browse files
Skip env_get_entry snapshot on non-buffered path (closes #228)
1 parent a68469a commit 39b2d44

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/builtins.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9498,11 +9498,11 @@ static Value builtin_valuein(Interpreter *interp, Value *args, int argc, Expr **
94989498
}
94999499

95009500
static int validate_read_metadata(Map *tpl, int *typing, int *recurse, int *shape, int explicit_typing,
9501-
int explicit_recurse, int explicit_shape);
9501+
int explicit_recurse, int explicit_shape);
95029502

95039503
// Helper: recursive validate implementation
95049504
static int validate_map_internal(Map *m, Map *tpl, int typing, int recurse, int shape, int explicit_typing,
9505-
int explicit_recurse, int explicit_shape) {
9505+
int explicit_recurse, int explicit_shape) {
95069506
if (!tpl) {
95079507
return 1;
95089508
}
@@ -9558,8 +9558,8 @@ static int validate_map_internal(Map *m, Map *tpl, int typing, int recurse, int
95589558
if (recurse && mval.type == VAL_MAP && tval.type == VAL_MAP) {
95599559
Map *mm = mval.as.map;
95609560
Map *tt = tval.as.map;
9561-
int ok =
9562-
validate_map_internal(mm, tt, typing, recurse, shape, explicit_typing, explicit_recurse, explicit_shape);
9561+
int ok = validate_map_internal(mm, tt, typing, recurse, shape, explicit_typing, explicit_recurse,
9562+
explicit_shape);
95639563
value_free(mval);
95649564
if (!ok) {
95659565
return 0;
@@ -9572,7 +9572,7 @@ static int validate_map_internal(Map *m, Map *tpl, int typing, int recurse, int
95729572
}
95739573

95749574
static int validate_read_metadata(Map *tpl, int *typing, int *recurse, int *shape, int explicit_typing,
9575-
int explicit_recurse, int explicit_shape) {
9575+
int explicit_recurse, int explicit_shape) {
95769576
Value validate_key = value_str("validate");
95779577
int found = 0;
95789578
Value validate_value = value_map_get((Value){.type = VAL_MAP, .as.map = tpl}, validate_key, &found);
@@ -9621,7 +9621,8 @@ static int validate_read_metadata(Map *tpl, int *typing, int *recurse, int *shap
96219621
}
96229622

96239623
// VALIDATE(map, schema, typing=0, recurse=0, shape=0):int
9624-
static Value builtin_validate(Interpreter *interp, Value *args, int argc, Expr **arg_nodes, Env *env, int line, int col) {
9624+
static Value builtin_validate(Interpreter *interp, Value *args, int argc, Expr **arg_nodes, Env *env, int line,
9625+
int col) {
96259626
(void)arg_nodes;
96269627
(void)env;
96279628
(void)argc;

src/env.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,8 @@ int env_permafreeze(Env *env, const char *name) {
796796
/* ================================================================== */
797797

798798
EnvEntry *env_get_entry(Env *env, const char *name) {
799-
EnvEntry *snap = env_entry_snap_alloc();
800799
if (ns_buffer_active() && !ns_buffer_is_prepare_thread()) {
800+
EnvEntry *snap = env_entry_snap_alloc();
801801
ns_buffer_read_lock(name);
802802
EnvEntry *entry = env_get_entry_raw(env, name);
803803
env_entry_snap_from_raw(snap, entry);
@@ -809,14 +809,7 @@ EnvEntry *env_get_entry(Env *env, const char *name) {
809809
return snap;
810810
}
811811

812-
EnvEntry *entry = env_get_entry_raw(env, name);
813-
env_entry_snap_from_raw(snap, entry);
814-
if (!entry) {
815-
// Clear to a canonical empty state and return NULL for not-found.
816-
env_entry_snap_clear(snap);
817-
return NULL;
818-
}
819-
return snap;
812+
return env_get_entry_raw(env, name);
820813
}
821814

822815
bool env_get(Env *env, const char *name, Value *out_value, DeclType *out_type, int *out_base, bool *out_initialized) {

0 commit comments

Comments
 (0)