diff options
author | Mike Pall <mike> | 2016-02-26 17:59:43 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2016-02-26 18:03:08 +0100 |
commit | 18f6aa97fd93df8e9964c2d22f20f16e6b71b72b (patch) | |
tree | fad1176f6c01dc1aaf36bafa0b73f22b8e1c37e4 /src/lj_meta.c | |
parent | 339a1fd69611e2fd084127ee11a36e57035639d1 (diff) | |
download | luajit-18f6aa97fd93df8e9964c2d22f20f16e6b71b72b.tar.gz luajit-18f6aa97fd93df8e9964c2d22f20f16e6b71b72b.tar.bz2 luajit-18f6aa97fd93df8e9964c2d22f20f16e6b71b72b.zip |
Use internal implementation for converting FP numbers to strings.
Contributed by Peter Cawley.
Diffstat (limited to 'src/lj_meta.c')
-rw-r--r-- | src/lj_meta.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lj_meta.c b/src/lj_meta.c index 104ecf07..de229571 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
@@ -278,25 +278,25 @@ TValue *lj_meta_cat(lua_State *L, TValue *top, int left) | |||
278 | */ | 278 | */ |
279 | TValue *e, *o = top; | 279 | TValue *e, *o = top; |
280 | uint64_t tlen = tvisstr(o) ? strV(o)->len : STRFMT_MAXBUF_NUM; | 280 | uint64_t tlen = tvisstr(o) ? strV(o)->len : STRFMT_MAXBUF_NUM; |
281 | char *p, *buf; | 281 | SBuf *sb; |
282 | do { | 282 | do { |
283 | o--; tlen += tvisstr(o) ? strV(o)->len : STRFMT_MAXBUF_NUM; | 283 | o--; tlen += tvisstr(o) ? strV(o)->len : STRFMT_MAXBUF_NUM; |
284 | } while (--left > 0 && (tvisstr(o-1) || tvisnumber(o-1))); | 284 | } while (--left > 0 && (tvisstr(o-1) || tvisnumber(o-1))); |
285 | if (tlen >= LJ_MAX_STR) lj_err_msg(L, LJ_ERR_STROV); | 285 | if (tlen >= LJ_MAX_STR) lj_err_msg(L, LJ_ERR_STROV); |
286 | p = buf = lj_buf_tmp(L, (MSize)tlen); | 286 | sb = lj_buf_tmp_(L); |
287 | lj_buf_more(sb, (MSize)tlen); | ||
287 | for (e = top, top = o; o <= e; o++) { | 288 | for (e = top, top = o; o <= e; o++) { |
288 | if (tvisstr(o)) { | 289 | if (tvisstr(o)) { |
289 | GCstr *s = strV(o); | 290 | GCstr *s = strV(o); |
290 | MSize len = s->len; | 291 | MSize len = s->len; |
291 | p = lj_buf_wmem(p, strdata(s), len); | 292 | lj_buf_putmem(sb, strdata(s), len); |
292 | } else if (tvisint(o)) { | 293 | } else if (tvisint(o)) { |
293 | p = lj_strfmt_wint(p, intV(o)); | 294 | lj_strfmt_putint(sb, intV(o)); |
294 | } else { | 295 | } else { |
295 | lua_assert(tvisnum(o)); | 296 | lj_strfmt_putfnum(sb, STRFMT_G14, numV(o)); |
296 | p = lj_strfmt_wnum(p, o); | ||
297 | } | 297 | } |
298 | } | 298 | } |
299 | setstrV(L, top, lj_str_new(L, buf, (size_t)(p-buf))); | 299 | setstrV(L, top, lj_buf_str(L, sb)); |
300 | } | 300 | } |
301 | } while (left >= 1); | 301 | } while (left >= 1); |
302 | if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { | 302 | if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { |