Efficient way to get all variable within a collection

I want to get all variables (not just id) within a collection, so I can check values and use as alias in another collection), but I don’t think there’s a direct way of doing so? Only variableids is available from collection.

So far, I can think of iterating over all local variables (from getlocalvariables) then filter by matching variablecollectionid.

Is there any other better way?