masterClass->playerManager->player[currentPlayer]->health = 100;
I was wondering how I can optimize this code to make it run faster... I have heard of adding a function inside of the player class, but I''m not sure how I would do this... any help on this issue is greatly appreciated. Thanks.
Code Optimization
I have found my code and this method to be extremely slow:
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
Maybe something like this?:
int *pointer_to_health = &masterClass->playerManager->player[currentPlayer]->health;*pointer_to_health = 100;
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
It's important to note that storing the pointer to health like that will only be a speed increase if you store that pointer, and don't get a new one each time you use it. And anyway, the speed increase would be extremely small.
I've gotta ask why you think that's what's slowing your code down? It's very very likely that something else is slowing it down.
Edited by - Qoy on September 18, 2000 1:36:42 AM
I've gotta ask why you think that's what's slowing your code down? It's very very likely that something else is slowing it down.
Edited by - Qoy on September 18, 2000 1:36:42 AM
Profile!
I have a pluggabel factory. I ran 20,000 iterations through it and cam back with 4,500,000...somethings... (I''m using a funky timer)... So I replace a function to pass by ref, down to 1,000,000, then implemented a memory pooling and preallocation scheme, dropped any assignments, dropped a few loops that could be calced outside the main loop.. 100,000...
Without the profiler I wouldn''t have known where to start. I was suprised to find the destructor in there, and I (previously) had no idea that a string would take so long to construct.
So, are your _sure_ it''s that dereference? I couldn''t account for more than a few clock cycles could it?
gimp
I have a pluggabel factory. I ran 20,000 iterations through it and cam back with 4,500,000...somethings... (I''m using a funky timer)... So I replace a function to pass by ref, down to 1,000,000, then implemented a memory pooling and preallocation scheme, dropped any assignments, dropped a few loops that could be calced outside the main loop.. 100,000...
Without the profiler I wouldn''t have known where to start. I was suprised to find the destructor in there, and I (previously) had no idea that a string would take so long to construct.
So, are your _sure_ it''s that dereference? I couldn''t account for more than a few clock cycles could it?
gimp
Chris Brodie
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement