Thread: nVault Tutorial
View Single Post
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-24-2016 , 13:44   Re: nVault Tutorial
Reply With Quote #93

You would need 11 bytes for STEAM_0:X:X.
But pawn needs 11 cells, which is 4 bytes each, so 44 bytes.
Now that is bare minimum and only applies to 10 persons in the world (of which I'm guessing none are playing).
My latest SteamID is STEAM_0:1:70253370, let's assume that at least one more character is used in general since most people playing CS are young and therefor new, so 19 is the magic number. 19*4 = 76 bytes per SteamID.
76 is a lot compared to 4, no matter how you see it. The integer written in string form can never exceed 11 characters (-X XXX XXX XXX). Which is the same as the absolute shortest SteamID possible.

The memory saving is useless.
But this is not a matter of CPU vs. memory. It's CPU vs. database speed and CPU vs. internet connection. And CPU is never as important as those other two. If it was you would get bottlenecked downloads because of a slow CPU, which is hard (wireless doesn't count because people using wireless for wired computers are idiots).
You could argue that you have to optimize your code to save and load as less frequent as possible, but the optimization follow along with that seamlessly and is probably still the better option.

I'm not saying everyone should do it. I know it's trivial. I always like to compare speed and efficiency but I know that in the end most of it will never matter.
However, a coder creating any kind of large project should consider all ways of making data as small as possible.

If I create something as an example, readability and the ability to understand it is the most important thing.
If I create an API, modularity is key.
If I create an internal function I don't care about readability nor modularity. Then speed is all that matters. As long as I understand it and can support it I'm fine with it.

This function breaks whenever we reach STEAM_0:X:2147483647. If or when that will happen is hard to say. Long term solution would be SteamID64 mashed into 2 bytes.
__________________

Last edited by Black Rose; 09-24-2016 at 13:50.
Black Rose is offline