Yes if you don't have many players on your server, this is pretty useless. In fact, I used this method to track all the graves from my Graves datapack in order to be able to remove them when uninstalling datapack. If this is used on a small server that can have around 100 players, with potentially 2 or 3 unopened graves per player, the data set can get a bit big.
I admit I did not conduct any test to see if it is really more efficient but I assumed that dividing your data set in smaller pieces would result in less copy operations (1 or 2 to get to the right array and up to a quarter of the original data set length for cycling through array). I don't know how much less effective it is to copy big set of data than a single element from an array.
The nesting I proposed can be made differently like dividing the main array in 10 pieces instead of 2