GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — buffer: added Buffer methods to r/w 24 bits integers. by rootslab · Pull Request #169 · nodejs/node

Conversation

@rootslab

@rootslab rootslab commented Dec 16, 2014

Copy link
Copy Markdown
Contributor

Added readInt24LE() readInt24BE(), readUInt24LE(), readUInt24BE(), writeInt24LE() writeInt24BE(), writeUInt24LE(), writeUInt24BE().
Added tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rootslab
buffer: added Buffer methods to r/w 24 bits integers.
b0ca62e
Added readInt24LE() readInt24BE(), readUInt24LE(), readUInt24BE().
Added tests.
@piscisaureus piscisaureus added the unknown label Dec 16, 2014
@rootslab

rootslab commented Dec 16, 2014

Copy link
Copy Markdown
Contributor Author

I have seen readUIntLE/readUIntBE/readIntUE.. methods, but I think it could be simpler (also faster) to have direct methods to read/write at least 24 bits / 3 bytes integers.
Why don't use direct methods also for 40 to 48 bits, it is a problem of code style/size/repetition?

@trevnorris @bnoordhuis if the PR sounds good, I can do another PR with updated docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@piscisaureus piscisaureus removed the unknown label Dec 16, 2014
@trevnorris

trevnorris commented Dec 17, 2014

Copy link
Copy Markdown
Contributor

Performance difference is on the order of sub 10 ns. I don't think adding additional methods to Buffer is really necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rootslab

rootslab commented Dec 18, 2014

Copy link
Copy Markdown
Contributor Author

Hi @trevnorris, Thanks for you reply.
My real point/intention is only to have direct API methods to read/write 24bits ints, "faster" is between () , because I know that speed is only a feature.

However, generally I deal with big Buffers ( > 1MB), you can see that exists a real gain (not ns), here a gist to run; see results, when the Buffer is small, improvements are not tangible, I agree, but if you deal a lot with bigger Buffers you can see a real difference in the long run. I see a gain up to 40% (then seconds).

P.S. The real difference is in writing Buffers, Sorry, I forget to mention write methods in the commit message!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rootslab

rootslab commented Dec 18, 2014

Copy link
Copy Markdown
Contributor Author

@trevnorris , As a last resort, can I appeal to Ecology?
Consume less CPU cycles! :DD

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rootslab rootslab closed this Dec 19, 2014
@rootslab

rootslab commented Dec 19, 2014

Copy link
Copy Markdown
Contributor Author

Hi @yorkie, thanks for your interest, simply, I read/write big chunks of values through Buffers.
I think I will publish some repos in the next weeks that deals with it.
However, no matter, I close the PR, I agree with @trevnorris, it's not so important. ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@algesten

algesten commented Dec 19, 2014

Copy link
Copy Markdown

@yorkie one thing that comes to mind is 24-bit audio. but then i'm not sure how people typically organise that kind of information in memory and on disk.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Dec 19, 2014

Copy link
Copy Markdown
Contributor

@rootslab I appreciate the insight, and I think there's probably a fast-path that can be managed in the general implementation for 24-bit. I mean, honestly, is there really a use case for 40/48 bit reads/writes? I just did it because it could be done. :P

That being said, I'll look into how to speed up the generalized case. Thanks for your PR, and more so for validation that 24 bit reads/writes are actually used.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rootslab

rootslab commented Dec 19, 2014

Copy link
Copy Markdown
Contributor Author

Hi @trevnorris, the only way that comes to my mind, to improve speed for generalized code, is to use an array to cache multipliers values from 1 to 6 bytes, but I think that you wouldn't like to use an array inside Buffer code, right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Dec 20, 2014

Copy link
Copy Markdown
Contributor

@rootslab Also can do something as simplistic as:

if (byteLength === 3)
  return ((this[offset]) |
      (this[offset + 1] << 8) |
      (this[offset + 2] << 16));
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rootslab

rootslab commented Dec 20, 2014

Copy link
Copy Markdown
Contributor Author

@trevnorris, ok, now I understand what you mean, you propose a test condition only for 24 bits in the generalized code, I agree with you ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kunalspathak added a commit to kunalspathak/node-chakracore that referenced this pull request Jan 23, 2017
@kunalspathak
chakrashim: Fix GetOwnPropertyNames and GetPropertyNames
9716837
As per spec `Object.getOwnPropertyNames()` and
`Object.getPropertyNames()` should return an array of strings.
However there is no standardization of what should happen if
these methods are called natively (through NaN for example).

For these 2 APIs, v8 returns an array containing mix of numbers
for numeric properties and strings for normal string properties.
This breaks [grpc](https://github.com/grpc/grpc) module because it
[expects](https://github.com/grpc/grpc/blob/master/src/node/ext/call.cc#L673-L683) returned values to be numeric.

Fix: Once we get the result from, iterate over the result and call
`parseInt` to save numeric value of the key.

PR-URL: nodejs/node#169
Reviewed-By: Jianchun Xu <[email protected]>
boingoing pushed a commit to boingoing/node that referenced this pull request Apr 6, 2017
@jasongin
Disable N-API by default (nodejs#169)
43dc439
@ryan-ally ryan-ally mentioned this pull request Mar 1, 2021
[Snyk] Upgrade remark-preset-lint-node from 2.0.0 to 2.0.1 ryan-ally/node#13
Open
This was referenced May 26, 2021
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 olegnn/node#29
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.0-beta.7 to 2.2.0 erdun/node#34
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 saeedahassan/node#28
Open
[Snyk] Upgrade remark-preset-lint-node from 1.16.0 to 2.2.0 molllyn1/node#4
Open
@snyk-bot snyk-bot mentioned this pull request Jun 28, 2021
[Snyk] Upgrade remark-preset-lint-node from 2.0.0 to 2.3.0 ramonbrugman/node#2
Open
@snyk-bot snyk-bot mentioned this pull request Jul 13, 2021
[Snyk] Upgrade remark-preset-lint-node from 2.0.0 to 2.3.0 Zintexiss/node-22#24
Open
@verdinjoshua1982 verdinjoshua1982 mentioned this pull request Oct 14, 2022
[Snyk] Upgrade pacote from 12.0.3 to 13.6.2 verdinjoshua1982/node#3
Open
@s4sc s4sc mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities s4sc/node#34
Open
@AyushG3112 AyushG3112 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities AyushG3112/node#36
Open
@thakursachin467 thakursachin467 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities thakursachin467/node#31
Open
@erdun erdun mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities erdun/node#54
Open
@olegnn olegnn mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities olegnn/node#48
Open
@RoeeOren RoeeOren mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities RoeeOren/node#43
Open
@aliceUnhinged613 aliceUnhinged613 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities aliceUnhinged613/node#102
Open
@solebox solebox mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities solebox/node#34
Open
@KamilPolivka KamilPolivka mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities KamilPolivka/node#31
Open
@karencapiiro karencapiiro mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities karencapiiro/node#30
Open
@nickfnblum nickfnblum mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities nickfnblum/node#12
Open
@137717unity 137717unity mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities 137717unity/node#110
Open
@ryan-ally ryan-ally mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities ryan-ally/node#90
Open
@bumplzz69 bumplzz69 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities bumplzz69/node#57
Open
@baby636 baby636 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities baby636/node#113
Open
@molllyn1 molllyn1 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities molllyn1/node#91
Open
@awaisab172 awaisab172 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities awaisab172/node#50
Open
@xphillyx xphillyx mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities xphillyx/node#27
Open
@AshdonG AshdonG mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities AshdonG/node#46
Open
@sirinartk sirinartk mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities sirinartk/node#49
Open
@BryanLaura BryanLaura mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities BryanLaura/node#66
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 3 vulnerabilities terrorizer1980/node-1#15
Open
@Verdinjoshua26 Verdinjoshua26 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Verdinjoshua26/node#54
Open
@Bhanditz Bhanditz mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Bhanditz/node#36
Open
@adamlaska adamlaska mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities adamlaska/node#129
Open
@Redwoodtj Redwoodtj mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Redwoodtj/node#11
Open
@wedataintelligence wedataintelligence mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities wedataintelligence/node#93
Open
@adamlaska adamlaska mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities adamlaska/node#131
Open
@enterstudio enterstudio mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities enterstudio/node#33
Open
@kaocher82 kaocher82 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Xtuden-com/node#39
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Exhorder6/node#24
Open
@Supermajestcd Supermajestcd mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Supermajestcd/node#18
Open
@ajesse11x ajesse11x mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities ajesse11x/node#46
Open
This was referenced Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities MaxMood96/node#39
Open
[Snyk] Fix for 1 vulnerabilities Mement-Mori/node#34
Open
@snyk-io snyk-io Bot mentioned this pull request Oct 21, 2024
[Snyk] Fix for 26 vulnerabilities Graybar-codespace/node#49
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rootslab @trevnorris @algesten @piscisaureus
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.