diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-21 07:02:02 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | df640dc7f55fef962b598562e10d8dd4d60fedc0 (patch) | |
tree | 2dfac59fa992ef1b42c3cc2ce9bc25c067f2ba82 /src/std/buffer.c | |
parent | c68fe7634341e97c3246b627a20fa9487586ffcb (diff) |
Code cleanup in ssa/bytecode. Remove ugly memcpy
Diffstat (limited to 'src/std/buffer.c')
-rw-r--r-- | src/std/buffer.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/std/buffer.c b/src/std/buffer.c index 93e8558..a482bb9 100644 --- a/src/std/buffer.c +++ b/src/std/buffer.c @@ -37,9 +37,12 @@ static CHECK_RESULT int buffer_ensure_capacity(Buffer *self, usize new_capacity) if(capacity == 0) { capacity = new_capacity; } else { - while(capacity < new_capacity) { - capacity *= 1.5; + double cap = capacity; + const double new_cap = new_capacity; + while(cap < new_cap) { + cap *= 1.5; } + capacity = cap; } alloc_result = am_realloc(self->data, capacity, &new_mem); |