-
-
Notifications
You must be signed in to change notification settings - Fork 677
Add Array#join and Array#toString + dtoa #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
std/assembly/array.ts
Outdated
} from "./internal/array"; | ||
|
||
import { itoa } from "./internal/itoa"; | ||
import { dtoa } from "./internal/dtoa"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe make this internal/number
holding all the number compatibility code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think parse<T>
should be also move to internal/number
. WDYT?
std/assembly/array.ts
Outdated
var hasSeparator = separator.length != 0; | ||
if (value instanceof bool) { | ||
for (let i = 0; i < lastIndex; ++i) { | ||
result += loadUnsafe<T,T>(buffer, i) ? "true" : "false"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a GC, string concatenation leaves behind unreferenced instances and building the string from scratch using low-level ops might be a better strategy there. Ideally, just the final step, when appending lastIndex, makes a proper string that can be handled by GC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For itoa
and especially dtoa
this pretty problematic because I don't forecast actual string length produced after stringify and can't preallocate one buffer. But I could allocate one buffer with maximum possible size. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this will require two pass (interation through array) logic
Great, thank you! :) |
Array#join
method;Array#toString
method;dtoa
method;dtoa
anditoa
tointernal/number
file;itoa
and add its generic and streaming versions;Array#includes
which now reusingArray#indexOf
;DONE
dtoa
dtoa
Array#join
Array#join