Differences between these exactly similar functions?

  1. Is calling the string function from string itself more efficient than calling the function on the string? string.len(“test”) vs. #”test”

Asking due to this being said in the Luau recap in June and unsure whether it applies to all functions in the string library.

  1. Any difference between :GetChildren() vs :GetPlayers() besides that :GetPlayers() only fetches players? No one would be placing non-Player Instances in the Players service would they?
  2. Is a numerical index iterator (for n = 1, #t do) better than an ipairs iterator for iterating arrays performance-wise?
  3. Filtering strings on TextService vs Chat service.

There’s probably more but this is all I found for now.

2 Likes

1: I’d stick with the operator because it looks better, but you can try to benchmark both. It’s unlikely to make a significant difference, though.

2: That is the difference, and …

… there are people who do that.

3: Last I checked, ipairs was slightly slower, but the difference is negligible. Here’s how fast each were after 10 million iterations (taking into account that you have to index the table to get the actual value in the length method)
image

(Sorry about the quality, I couldn’t copy the image properly. I’ll edit in the original in a few hours if it bugs anyone.)

4: The chat methods say they’re partially deprecated. I’d go with text service.

3 Likes