-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: add incr/decr operators for Reference #19083
src: add incr/decr operators for Reference #19083
Conversation
node-test-commit-windows-fanned failure looks unrelatednot ok 230 parallel/test-http2-https-fallback
---
duration_ms: 0.264
severity: fail
stack: |-
(node:3544) ExperimentalWarning: The http2 module is an experimental API.
assert.js:243
throw err;
^
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
assert.ok(/Unknown ALPN Protocol, expected `h2` to be available/.test(text))
at TLSSocket.tls.setEncoding.on.on.common.mustCall (c:\workspace\node-test-binary-windows\test\parallel\test-http2-https-fallback.js:143:9)
at TLSSocket.<anonymous> (c:\workspace\node-test-binary-windows\test\common\index.js:467:15)
at TLSSocket.emit (events.js:136:15)
at endReadableNT (_stream_readable.js:1021:12)
at process._tickCallback (internal/process/next_tick.js:115:19)
... |
This assert was recently introduced in #18986 Update: being addressed by #19093. |
src/aliased_buffer.h
Outdated
template <typename T> | ||
inline Reference& operator-=(const T& val) { | ||
const T current = aliased_buffer_->GetValue(index_); | ||
aliased_buffer_->SetValue(index_, current - val); |
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.
Unless I’m missing something, you could just do operator+=(index_, -val)
here. If you add an overload for the unary minus operator (or is that even necessary?), that should get rid of the overload below that takes in a const Reference&
.
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'll take a closer look at your suggestion on Monday (little short of time right now). Thanks
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.
@TimothyGu Please take a look and see if this was what you had in mind, thanks.
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.
@TimothyGu If possible I'd like get this merged but it would be great if you could take a look at the latest change and see if this is what you had in mind. Thanks
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.
Awesome, thank you!
src/aliased_buffer.h
Outdated
} | ||
|
||
inline Reference& operator-=(const Reference& val) { | ||
this->operator-=(static_cast<NativeT>(val)); |
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.
Just a suggestion, but I would personally find return *this -= static_cast<NativeT>(val);
a bit clearer/more idiomatic in these places.
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.
Ah yes, let me change that thanks!
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.
This is definitely still merge-able :)
|
||
template <typename T> | ||
inline Reference& operator-=(const T& val) { | ||
return this->operator+=(-val); |
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.
Just making sure, this still works if val
is a reference?
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.
Would definitely be good to test for that.
This commit adds operator overloads for increment/decrement to AliasedBuffer::Reference. The motivation for doing this is to hopefully make code that needs to increment/decrement a little simpler.
6802731
to
18f46e8
Compare
Test added and rebased CI: https://ci.nodejs.org/job/node-test-pull-request/13599/ |
This commit adds operator overloads for increment/decrement to AliasedBuffer::Reference. The motivation for doing this is to hopefully make code that needs to increment/decrement a little simpler. PR-URL: #19083 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Landed in 45277e2 |
This commit adds operator overloads for increment/decrement to AliasedBuffer::Reference. The motivation for doing this is to hopefully make code that needs to increment/decrement a little simpler. PR-URL: #19083 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit adds operator overloads for increment/decrement to AliasedBuffer::Reference. The motivation for doing this is to hopefully make code that needs to increment/decrement a little simpler. PR-URL: #19083 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit adds operator overloads for increment/decrement to AliasedBuffer::Reference. The motivation for doing this is to hopefully make code that needs to increment/decrement a little simpler. PR-URL: nodejs#19083 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Should this be backported to 8.x? If so, a separate backport PR is necessary. |
This commit adds operator overloads for increment/decrement to
AliasedBuffer::Reference.
The motivation for doing this is to hopefully make code that needs
to increment/decrement a little simpler.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src