refactor: extract wrenNewUninitializedString to avoid passing NULL to wrenNewString for empty buffers

This commit is contained in:
Bob Nystrom
2014-12-06 18:04:46 +00:00
parent 9b498b4638
commit 77bddf8f0a
3 changed files with 28 additions and 10 deletions
+1 -1
View File
@@ -957,7 +957,7 @@ DEF_NATIVE(string_subscript)
// The result is a one-character string.
// TODO: Handle UTF-8.
Value value = wrenNewString(vm, NULL, 2);
Value value = wrenNewUninitializedString(vm, 2);
ObjString* result = AS_STRING(value);
result->value[0] = AS_CSTRING(args[0])[index];
result->value[1] = '\0';