- Viewing Profile: Reputation: rip-off
Community Stats
- Group Moderators
- Active Posts 9,716
- Profile Views 11,156
- Member Title GDNet+
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
Awards
-
Awards
Expert Community Member
Blog post contributor
#4786789 Shouldn't Java be a scripting language?
Posted by rip-off
on 16 March 2011 - 05:19 PM
I don't see the distinction as being particularly useful anymore.
#4786709 How many of you use C for game programming?
Posted by rip-off
on 16 March 2011 - 01:38 PM
I don't see the point in this argument. The point here is the result. If the resulting executable is equally fast, then there is no "mistake". If I know the compiler will manage this for me, why should I waste precious brain cycles worrying about it, when I can put them to better use finding and eliminating bottlenecks. Your whole line of argument appears to be counter-productive and just pedantic really.I guess we're both having conflicting definitions of 'fix'. The mistake, in my mind, was using 'i++' when '++i' should have been used instead. In order for the compiler to 'fix' that mistake, it'd need to invoke the pre-increment instead of the post-increment operator. I disagree that the compiler can fix the mistake, however, I do agree that in some cases the compiler can hide the mistake.
Optimising for size doesn't change much. Here is the output assembly:
; 13 : // Print post
; 14 : for(std::vector<int>::iterator it = v.begin(); it != v.end(); it++) {
mov esi, ebx
cmp ebx, edi
je SHORT $LN4@main
$LL82@main:
; 15 : printf("%d\n", *it);
push DWORD PTR [esi]
push OFFSET $SG-31
call _printf
add esi, 4
pop ecx
pop ecx
cmp esi, edi
jne SHORT $LL82@main
$LN4@main:
; 16 : }
; 17 :
; 18 : // Print pre
; 19 : for(std::vector<int>::iterator it= v.begin(); it != v.end(); ++it) {
mov esi, ebx
cmp ebx, edi
je SHORT $LN1@main
$LL112@main:
; 20 : printf("%d\n", *it);
push DWORD PTR [esi]
push OFFSET $SG-32
call _printf
add esi, 4
pop ecx
pop ecx
cmp esi, edi
jne SHORT $LL112@main
$LN1@main:
Code speaks louder than words. Next time you make an assertion that can be trivially proven using code, kindly do so. It spares me the time debunking your statements.If you're putting your iterator implementation in a DLL and optimising for size then maybe you aren't too worried about performance after all.
#4786004 How to improve these C++ functions
Posted by rip-off
on 15 March 2011 - 06:56 AM
Why WIN_DOWS? There are already standard Windows definitions.
This is more curiosity than anything else, but what is the purpose of the template parameter to ReceiveCompressedBuffer, given that it is not used?
#4786003 Help with Recursion in C++
Posted by rip-off
on 15 March 2011 - 06:55 AM
#4785515 how to restrict client connect?
Posted by rip-off
on 14 March 2011 - 02:45 AM
#4784334 A brief history of C and computer programming?
Posted by rip-off
on 11 March 2011 - 05:07 AM
The forums are for mainly for technical discussion, with some exceptions including the lounge.
Your posts could do with more paragraphs to keep them readable. But the main thing they suffer from is bouncing all over the place. They are really hard to follow and you digress and digress again. If you want to rant about mining or the price of fuel don't do it in a thread about programming, it makes no sense; the topics are unrelated. I would make two blog posts about these topics, had I something to say about them.
Clarity and brevity would add much to your writing style. Knowing what to exclude is often the key to simple, understandable writing.
#4784310 How to get all instances of a class that was created with the new operator?
Posted by rip-off
on 11 March 2011 - 03:43 AM
std::list<MyClass*> MyClass::instances;You said earlier you had no main source file but you can put such definitions in any source file - which you must have at least one of anyway, for main().
Besides, I'm sure PhysX has some way of handling this... usually such libraries provide some "user data", often an opaque or void pointer, which you can set to whatever you want and you can retrieve in the callback. Such a suggestion is included in this thread.
If this allows you to avoid the global instance list, then I would recommend doing so.
#4783940 Already defined object, where?
Posted by rip-off
on 10 March 2011 - 04:10 AM
Of course, ideally you wouldn't need to access private data in non-member functions, but at the same time sometimes writing a small static function offers better encapsulation than exposing this private information in the public interface, which is available to all callers.
A classic example might be having private constructors and a public static function which returns an instance of the class. I sometimes do this so I can be more explicit about the nature of the constructor, SomeParser(true) or SomeParser(false) aren't as clear as SomeParser::buildCaseSensitive() and SomeParser::buildCaseInsensitive().
#4783239 [C++] Threads and CPU usage
Posted by rip-off
on 08 March 2011 - 01:28 PM
To eliminate bottlenecks, you must first understand them. I can guarantee you that either std::vector<> is being used incorrectly, or your bottleneck is that you are using the wrong data structure/algorithm and replacing it with a custom dynamic array will not help.
As Antheus mentioned, just passing the right set of flags to the compiler can result in a massive performance boost.
#4783077 Using arrays to create enemies...
Posted by rip-off
on 08 March 2011 - 05:54 AM
Manual dynamic allocation should be rare. You probably don't need it here.
#4782556 Variable Speed
Posted by rip-off
on 06 March 2011 - 03:46 PM
I suspect you might have a dual core processor, and the difference is that if your application is started on a "busier" core, that it will run fractionally slower. OSes try not to switch threads between processors if they can avoid it, because doing so is quite expensive. This is why it varies from run to run.
I don't think it is worth worrying about.
#4779382 Pointers
Posted by rip-off
on 26 February 2011 - 12:31 PM
#4778375 C++ Return CHAR variable
Posted by rip-off
on 24 February 2011 - 04:37 AM
Ok, let us look at your original code where you called userInput():
userInput(guessLetter);What you are doing here is passing a copy of the variable guessLetter to the function. The parameter is modified inside the function, but this doesn't matter as the modifications are to a local copy. You are not capturing the return value, so it is lost.
To get it to work, change the return type of userInput() to char, drop the parameter to the function (it is unnecessary) and change the line above to: guessLetter = userInput();.
Two other points. First, drop the character arrays, use std::string everywhere. Secondly, you should be able to write the entire program without using a single (non-constant) global variable. This means you have to pass and return more information to each function, but it will make your code easier to read and maintain.
#4777956 Platformer in SDL - Collisions
Posted by rip-off
on 23 February 2011 - 08:21 AM
#4777057 callback addresses in std::vector
Posted by rip-off
on 21 February 2011 - 09:59 AM
If "callback" is the name of the variable, what do you think the type is?bool registerCallback(int(*callback)(int,int,int,int*,float*))
<hr>Consider making your argument list a structure. It will ease maintenance if you decide to extend or change your signature in future. It is also a good idea to include a void pointer to opaque data, which allows for arbitrary state during callbacks. You might even be able to remove some of your parameters if you are including them "just in case".
- Home
- » Viewing Profile: Reputation: rip-off

Find content