Remove pairs() and ipairs() (#1150)

This commit is contained in:
quaywinn
2025-11-18 21:49:52 -05:00
committed by GitHub
parent ea70d89291
commit 31ec216a95
13 changed files with 17 additions and 17 deletions

View File

@@ -25,7 +25,7 @@
local function defaultTableDebug(buffer, input)
buffer:writeRaw("{")
for key, value in pairs(input) do
for key, value in input do
buffer:write("[{:?}] = {:?}", key, value)
if next(input, key) ~= nil then
@@ -50,7 +50,7 @@ local function defaultTableDebugExtended(buffer, input)
buffer:writeLineRaw("{")
buffer:indent()
for key, value in pairs(input) do
for key, value in input do
buffer:writeLine("[{:?}] = {:#?},", key, value)
end

View File

@@ -44,7 +44,7 @@ end
local function blendAlpha(alphaValues)
local alpha = 0
for _, value in pairs(alphaValues) do
for _, value in alphaValues do
alpha = alpha + (1 - alpha) * value
end

View File

@@ -74,7 +74,7 @@ local Assets = {
local function guardForTypos(name, map)
strict(name, map)
for key, child in pairs(map) do
for key, child in map do
if type(child) == "table" then
guardForTypos(("%s.%s"):format(name, key), child)
end

View File

@@ -15,7 +15,7 @@ local encodePatchUpdate = require(script.Parent.encodePatchUpdate)
return function(instanceMap, propertyChanges)
local patch = PatchSet.newEmpty()
for instance, properties in pairs(propertyChanges) do
for instance, properties in propertyChanges do
local instanceId = instanceMap.fromInstances[instance]
if instanceId == nil then

View File

@@ -10,7 +10,7 @@ return function(instance, instanceId, properties)
changedProperties = {},
}
for propertyName in pairs(properties) do
for propertyName in properties do
if propertyName == "Name" then
update.changedName = instance.Name
else

View File

@@ -14,7 +14,7 @@ local function merge(...)
local source = select(i, ...)
if source ~= nil then
for key, value in pairs(source) do
for key, value in source do
if value == None then
output[key] = nil
else

View File

@@ -63,7 +63,7 @@ function InstanceMap:__fmtDebug(output)
-- Collect all of the entries in the InstanceMap and sort them by their
-- label, which helps make our output deterministic.
local entries = {}
for id, instance in pairs(self.fromIds) do
for id, instance in self.fromIds do
local label = string.format("%s (%s)", instance:GetFullName(), instance.ClassName)
table.insert(entries, { id, label })
@@ -73,7 +73,7 @@ function InstanceMap:__fmtDebug(output)
return a[2] < b[2]
end)
for _, entry in ipairs(entries) do
for _, entry in entries do
output:writeLine("{}: {}", entry[1], entry[2])
end
@@ -227,7 +227,7 @@ function InstanceMap:__disconnectSignals(instance)
-- around the extra table. ValueBase objects force us to use multiple
-- signals to emulate the Instance.Changed event, however.
if typeof(signals) == "table" then
for _, signal in ipairs(signals) do
for _, signal in signals do
signal:Disconnect()
end
else

View File

@@ -38,13 +38,13 @@ local function trueEquals(a, b): boolean
-- For tables, try recursive deep equality
if typeA == "table" and typeB == "table" then
local checkedKeys = {}
for key, value in pairs(a) do
for key, value in a do
checkedKeys[key] = true
if not trueEquals(value, b[key]) then
return false
end
end
for key, value in pairs(b) do
for key, value in b do
if checkedKeys[key] then
continue
end

View File

@@ -14,7 +14,7 @@ return function()
local function size(dict)
local len = 0
for _ in pairs(dict) do
for _ in dict do
len = len + 1
end

View File

@@ -26,7 +26,7 @@ local function hydrate(instanceMap, virtualInstances, rootId, rootInstance)
for _, childId in ipairs(virtualInstance.Children) do
local virtualChild = virtualInstances[childId]
for childIndex, childInstance in ipairs(existingChildren) do
for childIndex, childInstance in existingChildren do
if not isExistingChildVisited[childIndex] then
-- We guard accessing Name and ClassName in order to avoid
-- tripping over children of DataModel that Rojo won't have

View File

@@ -126,7 +126,7 @@ function applyDeferredRefs(instanceMap, deferredRefs, unappliedPatch)
})
end
for _, entry in ipairs(deferredRefs) do
for _, entry in deferredRefs do
local _, refId = next(entry.virtualValue)
if refId == nil then

View File

@@ -12,7 +12,7 @@ return function()
local function size(dict)
local len = 0
for _ in pairs(dict) do
for _ in dict do
len = len + 1
end

View File

@@ -9,7 +9,7 @@ local gatherAssetUrlsRecursive
function gatherAssetUrlsRecursive(currentTable, currentUrls)
currentUrls = currentUrls or {}
for _, value in pairs(currentTable) do
for _, value in currentTable do
if typeof(value) == "string" then
table.insert(currentUrls, value)
elseif typeof(value) == "table" then