Skip to content

Commit

Permalink
fix pooled length cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
ihciah committed Nov 11, 2024
1 parent a10d07c commit 1289164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion examples/example-monoio/go/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,13 @@ func new_list_mapper[T1, T2 any](f func(T1) T2) func(C.ListRef) []T2 {
// if the capacity is not enough, create a new one
// old one will not be used anymore
output = make([]T2, len(input))
} else if len(output) < len(input) {
var t2 T2
for i, il := len(output), len(input); i < il; i++ {
output = append(output, t2)
}
} else {
// if the capacity is enough, truncate the slice
// if the len is enough, truncate the slice
output = output[:len(input)]
}
} else {
Expand Down
7 changes: 6 additions & 1 deletion rust2go-common/src/raw_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,13 @@ typedef struct QueueMeta {
// if the capacity is not enough, create a new one
// old one will not be used anymore
output = make([]T2, len(input))
} else if len(output) < len(input) {
var t2 T2
for i, il := len(output), len(input); i < il; i++ {
output = append(output, t2)
}
} else {
// if the capacity is enough, truncate the slice
// if the len is enough, truncate the slice
output = output[:len(input)]
}
} else {
Expand Down

0 comments on commit 1289164

Please sign in to comment.