Would an array be more size-friendly than a dictionary?

Hey everyone, I have a simple question regarding whether I should switch to a dictionary rather than using an array. My concern is the size of the table; I’m sending information from the server to the client and I’m worried that my table is getting too large. I originally created this with a dictionary simply to make it easier on myself when sorting through the values.

I currently send the client a table with the information about every weapon in my game (name, asset id, whether the player has discovered it, how recently they discovered it, in-game rarity, is it’s new), here’s a visual:

{
	["Name"] = "Linked Sword",
	["AssetId"] = 125013769,
	["Discovered"] = false,
	["Recency"] = 0, -- This is a number other than 0 if they've 
	-- found it; smaller is more recent.
	["Rarity"] = "Common",
	["New"] = false
}

I decided to copy the resulting table with repr and pasted it online in a size calculator and got ~20KB. This includes the above information for 175+ weapons and worries me if I were to add more in the future. It’s worth mentioning that this would be sent whenever the player discovers a new gear, which would be somewhere between ten seconds and a minute for the first while as they discover a new one each time. After some time, it would likely slow to once every 10 minutes or so.

Would my table be large enough that it could cause some trouble? If I changed everything to an array, would it make a noticeable improvement? Something like this:

{
	"Linked Sword",
	125013769,
	false,
	0,
	"Common",
	false
}

All input is appricated, thanks.

3 Likes

I think you should concern yourself more with how much you’re sending and why rather than if you should switch between an array or a dictionary. As far as size goes, they’re probably relatively the same and either or has a negligible difference in use.

Just keep in mind the bandwidth limitation of 50KB/s for sending data via remotes.

2 Likes

That’s a fair point, I could modify it so that I send it all only once and then send what’s changed each time. When I was originally planning it out, I hadn’t considered size to be a problem. Thanks for the insight.

1 Like

I believe the amount of characters you use does in fact make a direct difference. In this case, you would be using almost half of the characters by switching to a table.

I would recommend making this change, as you would potentially reduce your stored information by 50%.

2 Likes