score_under
|
|
Reply #15 Posted on: December 10, 2009, 03:54:30 pm |
|
|
Joined: Aug 2008
Posts: 308
|
I'm relatively new with C++ so maybe I have completely missed something in terms of efficiency (since its over 650 lines).
You write code like: *q++ = *p++; *q = '\0'; That's better than most C++ programmers. They just use array indices, which means adding a variable to another variable from memory *every loop iteration*. Not to mention it's completely unnecessary. The only 2 problems I have with that specific function is that the *q='\0'; could firstly be *q=0;, and that it could be right before the calls to mkdir (to avoid writing a null byte every loop iteration, only to be overwritten the next iteration). You can also use arguments as variables - try that with __fastcall!
|
|
« Last Edit: December 10, 2009, 03:59:52 pm by score_under »
|
Logged
|
|
|
|
serprex
|
|
Reply #16 Posted on: December 10, 2009, 04:34:29 pm |
|
|
Smooth ER
Joined: Apr 2008
Posts: 106
|
glBegin(GL_LINE_LOOP | GL_QUADS ) GL_LINE_LOOP=2 GL_QUADS=7 7|2=7=GL_QUADS glBegin(GL_QUADS) Git repo patched
|
|
« Last Edit: December 10, 2009, 05:05:14 pm by serprex »
|
Logged
|
|
|
|
luiscubal
|
|
Reply #17 Posted on: December 10, 2009, 06:10:07 pm |
|
|
Joined: Jun 2009
Posts: 452
|
There's nothing wrong with array indexes. Nowadays, runtime execution speed seems to be less important than maintainability and premature optimization is considered harmful. That said, there's nothing wrong with C++ pointer arithmetic either, provided that it doesn't hurt code readability.
Theoretically, const should allow better optimization than variables. But that's just in theory. A good optimizer should detect constant variables... in theory. In practice, when something is a const, mark it as a const. There's no harm in it at all, it might improve readability and maybe(just maybe) it might improve performance. Anyway, I seriously doubt it'd worsen performance.
|
|
|
Logged
|
|
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #21 Posted on: December 11, 2009, 04:01:42 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Eh, showborder?GL_LINE_LOOP:GL_QUADS will suffice. Keep in mind var::operator bool() will cover that. And if they're simply passing .5 as a literal, I don't care if it turns out that it doesn't behave exactly like GM; the only reason someone would do that was if they were just trying to find some difference to shove in our noses.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
Josh @ Dreamland
|
|
Reply #23 Posted on: December 12, 2009, 03:27:10 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Fuck, he's right. *dumps three months of work*
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|