Commit 3be49d6
src: prevent extra copies of
I noticed that we were taking `TimerCb` as a `const&` and then copying
that into the member. This is completely fine when the constructor is
called with an lvalue. However, when called with an rvalue, we can allow
the `std::function` to be moved into the member instead of falling back
to a copy, so I changed the constructors to take in universal
references. Also, `std::function` constructors can take in multiple
arguments, so I further modified the constructors to use variadic
templates.
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
PR-URL: #40665
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>TimerWrap::TimerCb
1 parent a5a1691 commit 3be49d6Copy full SHA for 3be49d6
File tree
Expand file treeCollapse file tree
5 files changed
+42
-20
lines changedOpen diff view settings
Filter options
- src
Expand file treeCollapse file tree
5 files changed
+42
-20
lines changedOpen diff view settings
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
642 | 642 | |
643 | 643 | |
644 | 644 | |
| 645 | + |
645 | 646 | |
646 | 647 | |
647 | 648 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | | - |
| 18 | + |
19 | 19 | |
20 | 20 | |
21 | 21 | |
|
Collapse file
src/timer_wrap-inl.h
Copy file name to clipboard+32Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
Collapse file
+3-15Lines changed: 3 additions & 15 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
1 | 4 | |
2 | 5 | |
3 | | - |
4 | 6 | |
5 | 7 | |
6 | 8 | |
7 | 9 | |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | 10 | |
16 | 11 | |
17 | 12 | |
| ||
48 | 43 | |
49 | 44 | |
50 | 45 | |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | 46 | |
59 | 47 | |
60 | 48 | |
|
Collapse file
+5-4Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | | - |
| 19 | + |
| 20 | + |
| 21 | + |
20 | 22 | |
21 | 23 | |
22 | 24 | |
| ||
50 | 52 | |
51 | 53 | |
52 | 54 | |
53 | | - |
54 | | - |
55 | | - |
| 55 | + |
| 56 | + |
56 | 57 | |
57 | 58 | |
58 | 59 | |
|
0 commit comments