From 910906db584ee983db19da46ef95b306339117fe Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Mon, 9 Oct 2023 03:18:53 -0300 Subject: [PATCH] Fixed bins code --- gm/bins.v | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gm/bins.v b/gm/bins.v index b420b90e5..145ccf70d 100644 --- a/gm/bins.v +++ b/gm/bins.v @@ -89,14 +89,12 @@ pub fn (mut o Bins) append(x []f64, id int, extra voidptr) { if idx < 0 { errors.vsl_panic('coordinates ${x} are out of range', .erange) } - bin := o.find_bin_by_index(idx) + mut bin := o.find_bin_by_index(idx) if isnil(bin) { errors.vsl_panic('bin index ${idx} is out of range', .erange) } xcopy := x.clone() - entry := BinEntry{id, xcopy, extra} - mut entries := unsafe { bin.entries } - entries << &entry + bin.entries << &BinEntry{id, xcopy, extra} } // clear clears all biBinsns @@ -357,9 +355,9 @@ pub fn (o Bin) str() string { if i > 0 { l += ', ' } - l += "{\"id\":${entry.id}, \"x\":[${entry.x}[0],${entry.x}[1]" + l += "{\"id\":${entry.id}, \"x\":[${entry.x[0]},${entry.x[1]}" if entry.x.len > 2 { - l += ',${entry.x}[2]' + l += ',${entry.x[2]}' } l += ']' if !isnil(entry.extra) {