mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
use multipointers instead of simple pointers
This commit is contained in:
+6
-10
@@ -306,21 +306,17 @@ filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) -
|
|||||||
|
|
||||||
scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U)->V, allocator := context.allocator) -> []V {
|
scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U)->V, allocator := context.allocator) -> []V {
|
||||||
if len(s) == 0 { return {} }
|
if len(s) == 0 { return {} }
|
||||||
p := as_ptr(s)
|
|
||||||
|
|
||||||
res := make([]V, len(s), allocator)
|
res := make([]V, len(s), allocator)
|
||||||
|
p := as_ptr(s)
|
||||||
q := as_ptr(res)
|
q := as_ptr(res)
|
||||||
l := len(res)
|
|
||||||
|
|
||||||
r := initializer
|
r := initializer
|
||||||
|
|
||||||
for l > 0 {
|
for l := len(s); l > 0; l -= 1 {
|
||||||
r = f(r, p^)
|
r = f(r, p[0])
|
||||||
q^ = r
|
q[0] = r
|
||||||
p = intrinsics.ptr_offset(p, 1)
|
p = p[1:]
|
||||||
q = intrinsics.ptr_offset(q, 1)
|
q = q[1:]
|
||||||
l -= 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user