Bug 700169 - Refactor code to use StringBuffer. r=Waldo

This commit is contained in:
Tom Schuster
2011-12-06 11:31:00 +01:00
parent 0759db913f
commit bde1993ca3
8 changed files with 162 additions and 246 deletions

View File

@@ -533,16 +533,14 @@ num_toSource(JSContext *cx, uintN argc, Value *vp)
if (!BoxedPrimitiveMethodGuard(cx, args, num_toSource, &d, &ok))
return ok;
ToCStringBuf cbuf;
char *numStr = NumberToCString(cx, &cbuf, d);
if (!numStr) {
JS_ReportOutOfMemory(cx);
StringBuffer sb(cx);
if (!sb.append("(new Number(") || !NumberValueToStringBuffer(cx, NumberValue(d), sb) ||
!sb.append("))"))
{
return false;
}
char buf[64];
JS_snprintf(buf, sizeof buf, "(new %s(%s))", NumberClass.name, numStr);
JSString *str = js_NewStringCopyZ(cx, buf);
JSString *str = sb.finishString();
if (!str)
return false;
args.rval().setString(str);