-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/plat 1613 webstream #58
Conversation
# Conflicts: # lib/facade/FileClient.ts # lib/tdf3/src/client/builders.js # lib/tdf3/src/crypto/node-crypto-service.ts # lib/tdf3/src/utils/chunkers.ts
If these changes look good, signoff on them with:
If they aren't any good, please remove them with:
|
Signed-off-by: sivanov <sivanov.ctr@virtru.com>
4e527ed
to
fdbce5d
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
You can take or leave my comment on the toBuffer
method
|
||
while (!done) { | ||
const result = await reader.read(); | ||
if (result.value) { |
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.
Sorry I'm rabbit holing on this. This is a O(n²) algorithm, so I'd rather not do this. An ideal algorithm is probably something like https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/src/share/classes/java/util/ArrayList.java#l237.
However, it roughly the same worst case space performance as just creating a list so I'm inclined to do that instead. This would then be two pass algorithm - first build a standard array of TypedArrays and count the bytes, then allocate memory and assign in a second loop
Alternatively if you want to save a bit of memory you can try some hybrid or space aware approach.
Also does it really need to be a Buffer buffer instead of something that implements the Buffer interface? An alternative is to just implement a 'fractured' buffer but I'm guessing that isn't something we can entertain at the moment
No description provided.