Skip to content

Commit

Permalink
Fixed bins code
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Oct 9, 2023
1 parent 047fbef commit 910906d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gm/bins.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 910906d

Please sign in to comment.