Skip to content
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

src: use const parameters in base64_decode_slow() #12144

Closed
wants to merge 1 commit into from

Conversation

aqrln
Copy link
Contributor

@aqrln aqrln commented Mar 31, 2017

Make parameters as const since it's both better at its own and consistent with base64_decode_fast() and base64_decode().

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. labels Mar 31, 2017
Make parameters as const since it's both better at its own and
consistent with base64_decode_fast() and base64_decode().
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t base64_decode_slow(char* dst, size_t dstlen,
const TypeName* src, size_t srclen) {
size_t base64_decode_slow(char* const dst, const size_t dstlen,
const TypeName* const src, const size_t srclen) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the second const for src necessary?

Copy link
Contributor Author

@aqrln aqrln Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary, but why not add it if we don't mutate the pointer? And that would be consistent with base64_decode_slow() (line 90) and base64_decode() (line 122).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardlau The first const declares the pointed-to memory immutable, the second one declares the pointer itself immutable (i.e., not reassignable.)

@aqrln
Copy link
Contributor Author

aqrln commented Mar 31, 2017

Well, I've just tried to do something more interesting, so this PR will be a bit obsolete if everything's okay with #12146.

@addaleax addaleax added the blocked PRs that are blocked by other issues or PRs. label Apr 3, 2017
@aqrln
Copy link
Contributor Author

aqrln commented Apr 4, 2017

Closing this as #12146 has landed.

@aqrln aqrln closed this Apr 4, 2017
@aqrln aqrln deleted the base64-const-parameters branch July 31, 2017 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants