3 ms·
I said this elsewhere, but I would legitimately like to see a program like what the author wrote, written in idiomatic C++ that performs as well as what the aut
by FreezerburnV 8y ago
I said this elsewhere, but I would legitimately like to see a program like what the author wrote, written in idiomatic C++ that performs as well as what the author got to. Maybe in a comparison style like the author to show the slower C++, the faster "C with classes", and the comparable speed "idiomatic C++" or something. I feel like I see people saying that idiomatic C++ is just as fast as something, while other people say that idiomatic C++ is slower and should be replaced. I'm going to assume you can for sure write C++ using the STL to be just as fast, and would like to learn what needs to be done to get to that point so I can incorporate those techniques into my own C++ code where I might need that extra bit of performance. (I'm playing around with writing games in C++, so performance is more of a concern than an IO-heavy web server. Or I'm considering learning QT for making apps, etc.)
- mynegation 8y agoAuthor posted C version of their code[1]. As a couple of examples of how you can go back to idiomatic C++ starting from here: 1. replace all pointers by passing references to templatized vectors. On a high level of optimization they will be compiled to the same pointer arithmetic as C, but will give you type-safety on the source level. 2. Replace structs with clasess with short inlined accessors. On a high level of optimization they will be compiled to the same memory offset access 3. _If_ there is any value in making domain-specific sort generic - make it such [1] https://gist.github.com/zeux/bf847986e0474cf48f61bb5749da38e4 https://gist.github.com/zeux/bf847986e0474cf48f61bb5749da38e...