3 ms·
Really it's the other way around: peek is complex so the compiler didn't inline it. In essence, you do a virtual call which I think winds you up in https://git
by Veedrac 9y ago
Really it's the other way around: peek is complex so the compiler didn't inline it. In essence, you do a virtual call which I think winds you up in
https://github.com/gcc-mirror/gcc/blob/1cb6c2eb3b8361d850be8e8270c597270a1a7967/libstdc%2B%2B-v3/include/bits/istream.tcc#L620 https://github.com/gcc-mirror/gcc/blob/1cb6c2eb3b8361d850be8...
which itself redirects to a whole bunch of stuff.
The virtual call alone is a lot more expensive than a simple pointer dereference, and though it's possible proper inlining might have alleviated some of this problem, you're not particularly likely to see it come close to something that's efficient by design.