Skip to content

Commit

Permalink
Oops, forgot to make coerce_u_s use exact length
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterDuke17 committed May 2, 2024
1 parent 62e6467 commit c1eedd5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ MVMString * MVM_coerce_i_s(MVMThreadContext *tc, MVMint64 i) {

MVMString * MVM_coerce_u_s(MVMThreadContext *tc, MVMuint64 i) {
/* See if we can hit the cache. */
int cache = i < MVM_INT_TO_STR_CACHE_SIZE;
const int cache = i < MVM_INT_TO_STR_CACHE_SIZE;
if (cache) {
MVMString *cached = tc->instance->int_to_str_cache[i];
if (cached)
return cached;
}
/* Otherwise, need to do the work; cache it if in range. */
char *buffer = MVM_malloc(20);
int len = u64toa_jeaiii(i, buffer) - buffer;
const int msb = 64 - __builtin_clzll(i | 1);
char *buffer = MVM_malloc(mag[msb]);
const int len = u64toa_jeaiii(i, buffer) - buffer;
if (0 <= len) {
MVMString *result = MVM_string_ascii_from_buf_nocheck(tc, (MVMGrapheme8 *)buffer, len);
if (cache)
Expand Down

0 comments on commit c1eedd5

Please sign in to comment.