Reputation: 591
I have a MMORPG emulator, this means it will be handling packets quite a bit. Currently, I am using pointers for this, as I think when used correctly, they can speed up my server, however I've got two friends, one is telling me to use pointers, he thinks I can use them without running into trouble, my other friends says I should not use pointers, as they could make my server crash, they are unsafe, and they aren't easy to manage.
I use structs for my packet structures, so e.g. I could get its type using the following line: Ptr->Type;
What do you think?
Upvotes: 4
Views: 455
Reputation: 1484
I think you should probably test the performance with and without pointers, and then see for yourself if the gains in performance, if any, are worth the extra complexity of using pointers.
Chances are you'll find most of the your porgram's time is spent sitting there twiddling its thumbs doing nothing while waiting on network traffic.
Upvotes: 8
Reputation: 8190
In a way, they're both right. If you handle them propertly, pointers are much faster. On the other hand, if you don't handle them correctly, they can cause all kinds of problems.
If you think you've got a handle on it (and your friend(s) who is (are) knowledgable about pointers are willing to help you) go with pointers.
Upvotes: 6
Reputation: 117300
If you know what you are doing, then using pointers as you mentioned, would be a lot faster than any other form of de/serialization.
Upvotes: 3