This commit is contained in:
dcode
2019-03-13 03:09:24 +01:00
parent 36d54d63d5
commit e78c4c7f54
5 changed files with 149 additions and 90 deletions

View File

@ -9,7 +9,7 @@ import {
parse,
CharCode,
isWhiteSpaceOrLineTerminator
} from "./internal/string";
} from "./util/string";
@sealed export class String extends StringBase {
@ -431,8 +431,8 @@ import {
return len;
}
static fromUTF8(ptr: usize, len: usize): String {
if (len < 1) return changetype<String>("");
static fromUTF8(ptr: usize, len: usize): string {
if (len < 1) return changetype<string>("");
var ptrPos = <usize>0;
var buf = memory.allocate(<usize>len << 1);
var bufPos = <usize>0;
@ -468,10 +468,10 @@ import {
}
}
assert(ptrPos == len);
var out = ALLOC(<u32>(bufPos >> 1));
var out = ALLOC(bufPos);
memory.copy(changetype<usize>(out), buf, bufPos);
memory.free(buf);
return REGISTER<String>(out);
return REGISTER<string>(out);
}
toUTF8(): usize {