Minor optimization: emplace_back neighbors#3086
Conversation
|
Huh, really? Both of those should end up turning into the same machine code. It's cleaner the new way, so a good change regardless. But are you sure it's really faster? I would only expect a difference if compiled without compiler optimizations and/or with DLIB_ASSERT enabled. |
Hmm, good question. I did measure, and I did look at the profiler reports before and after the change – but not too rigorously perhaps. Also, this (legacy) project uses an older version of the compiler, which may explain something (?). Also, optimizations should be enabled and assertions disabled, but I can't really say I triple-checked everything. I could go back and do more measurements if needed, but I guess that's not really necessary. |
|
Na, no need. Just curious. |
I maintain an application that calls
label_connected_blobsa lot. Noticed while profiling that the code that collects apoint's neighbors is a bit of a hotspot there, and it seems that this small (and hopefully rather uncontroversial) change makes a measurable (even if not huge) difference.