builtin: fix map.zeros_to_end (#9689)

pull/9700/head
ka-weihe 2021-04-11 23:36:02 +02:00 committed by GitHub
parent 79fa15ec3a
commit 0facc5a559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -175,6 +175,7 @@ fn (mut d DenseArray) zeros_to_end() {
if d.has_index(i) {
// swap (TODO: optimize)
unsafe {
if count != i {
// Swap keys
C.memcpy(tmp_key, d.key(count), d.key_bytes)
C.memcpy(d.key(count), d.key(i), d.key_bytes)
@ -184,6 +185,7 @@ fn (mut d DenseArray) zeros_to_end() {
C.memcpy(d.value(count), d.value(i), d.value_bytes)
C.memcpy(d.value(i), tmp_value, d.value_bytes)
}
}
count++
}
}