Commit 70b41ea
committed
src/mgr/ClusterState.cc: micro improve ingest_pgstats
As I was going through ClusterState::ingest_pgstats
I noticed some refractor + mini-optimization we can do
with iterators and how we are inserting in a map container.
Propose caching the end() iterator of map
and use insert_or_assign() when adding new or updating values.
insert_or_assign() is better than [] in that pg_stat_t contain
some vectors and maps, so for adding new pgs or new keys
insert_or_assign() will do a direct copy-construction, rather than
default construction and assign values which arguable has more
overhead.
Signed-off-by: Kamoltat Sirivadhna <[email protected]>1 parent d9060d7 commit 70b41ea
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
120 | | - | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | | - | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | | - | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
0 commit comments