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: do not use std::function for OnScopeLeave #30134

Closed
wants to merge 3 commits into from

Conversation

addaleax
Copy link
Member

Using std::function adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.

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

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Oct 26, 2019
src/util.h Show resolved Hide resolved
src/util.h Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Oct 26, 2019
@addaleax
Copy link
Member Author

Hm … looks like Windows doesn’t like this?

I’ve added a move operator for the struct, I could imagine that MSVC added a copy operation when returning the value from the OnScopeLeave() helper function. Let’s see what CI says…

@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 1, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member Author

addaleax commented Nov 7, 2019

Landed in 6072e01

@addaleax addaleax closed this Nov 7, 2019
@addaleax addaleax deleted the onscopeleave-nostdfun branch November 7, 2019 09:45
addaleax added a commit that referenced this pull request Nov 7, 2019
Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.

PR-URL: #30134
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 17, 2019
Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.

PR-URL: #30134
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Nov 19, 2019
@targos
Copy link
Member

targos commented Dec 1, 2019

To land on v12.x, this should either wait for #29874, or be backported.

MylesBorins pushed a commit that referenced this pull request Jan 10, 2020
Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.

PR-URL: #30134
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
Using `std::function` adds an extra layer of indirection, and in
particular, heap allocations that are not necessary in our use case
here.

PR-URL: #30134
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants