Basically the title. I’m looking for micro-optimizations for my script and was just wondering if it was less expensive to send a table containing multiple information, or if it would be more expensive to send the required arguments with a table or sending it as a tuple?
For me, when more data is sent, more time will take the script to send data to a Remove Event/Function. In this case, the table send more information because is not just the data, it’s also the index of the data.
Aditional info
But take in mind…
When you send a table, only table data indexed by a number will be passed. For example:
Local script:
remoteEvent:FireServer({--[[This data is indexed by a number]][1] = "Hello"; --[[This data is indexed by a key]]Msg = "Hi"})
I am guessing the first line would be more optimized, kind of, because with the table, you are sending the table and then variables in it. I might be wrong
Data should be sent regardless of its index. It’s only functions and metadata that don’t get passed iirc.
Edit: yeah, just checked the page you linked. What happens is with mixed-index tables. So,
local table = {[1] = '1'; ['string'] = 'str';} -- only [1] = '1' would be passed
whereas
local table = {['string1'] = 'str1'; ['str2'] = 'str2'}
I did a little testing to see how much faster one is over the other, and the outcome of the results was that sending multiple arguments is pretty much the same as firing a remote with a table parameter.
I did find that multiple arguments were ever so slightly faster by an amount that would probably not be noticeable to the human eye, but in general, they can be used interchangeably.
One thing to note is that using several parameters might make your code readability much more difficult, and it is just best practice to use a set amount of parameters (I usually cap at 3), so if you feel like your functions need over like 6 parameters, you should consider just using tables