Commit 24b9ffa4 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Avoid creation of temporary String objects

We were converting an int to a Smi, calling ToString to create a String
object, then appending this String to an IncrementalStringBuilder.
It's much easier and more efficient to just sprintf to a local buffer
and append that instead.

R=titzer@chromium.org, ahaas@chromium.org
BUG=v8:5822

Change-Id: I9302a07971cfd32350d69b1b8f182d0ba7245b77
Reviewed-on: https://chromium-review.googlesource.com/454018Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43857}
parent bba1bc41
......@@ -686,13 +686,14 @@ MaybeHandle<String> WasmStackFrame::ToString() {
builder.AppendCString(" (<WASM>[");
Handle<Smi> ix(Smi::FromInt(wasm_func_index_), isolate_);
builder.AppendString(isolate_->factory()->NumberToString(ix));
char buffer[16];
SNPrintF(ArrayVector(buffer), "%u", wasm_func_index_);
builder.AppendCString(buffer);
builder.AppendCString("]+");
Handle<Object> pos(Smi::FromInt(GetPosition()), isolate_);
builder.AppendString(isolate_->factory()->NumberToString(pos));
SNPrintF(ArrayVector(buffer), "%d", GetPosition());
builder.AppendCString(buffer);
builder.AppendCString(")");
return builder.Finish();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment