News for hackers. Stuff that matters.
Re:For processing strings, streams in C++ can be slow by danpla on Thursday December 07, 2023 @07:29AM (#38555624)
> Anything object oriented is slower than anything procedural.

Well, that's not always true; it's better to use a profiler.

In many cases, it's trivial for the compiler to inline objects (e.g., used as predicates for <algorithm> routines), resulting in better performance compared to the equivalent procedural code.

> running constructors and destructors is expensive

If the object is not polymorphic (and sometimes even if it is), the compiler can inline both the constructor and destructor, resulting in exactly the same assembly output as the procedural code.

There are no comments on this comment yet.