mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 07:06:12 +00:00
Remove pairs() and ipairs() (#1150)
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
local function defaultTableDebug(buffer, input)
|
local function defaultTableDebug(buffer, input)
|
||||||
buffer:writeRaw("{")
|
buffer:writeRaw("{")
|
||||||
|
|
||||||
for key, value in pairs(input) do
|
for key, value in input do
|
||||||
buffer:write("[{:?}] = {:?}", key, value)
|
buffer:write("[{:?}] = {:?}", key, value)
|
||||||
|
|
||||||
if next(input, key) ~= nil then
|
if next(input, key) ~= nil then
|
||||||
@@ -50,7 +50,7 @@ local function defaultTableDebugExtended(buffer, input)
|
|||||||
buffer:writeLineRaw("{")
|
buffer:writeLineRaw("{")
|
||||||
buffer:indent()
|
buffer:indent()
|
||||||
|
|
||||||
for key, value in pairs(input) do
|
for key, value in input do
|
||||||
buffer:writeLine("[{:?}] = {:#?},", key, value)
|
buffer:writeLine("[{:?}] = {:#?},", key, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ end
|
|||||||
local function blendAlpha(alphaValues)
|
local function blendAlpha(alphaValues)
|
||||||
local alpha = 0
|
local alpha = 0
|
||||||
|
|
||||||
for _, value in pairs(alphaValues) do
|
for _, value in alphaValues do
|
||||||
alpha = alpha + (1 - alpha) * value
|
alpha = alpha + (1 - alpha) * value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ local Assets = {
|
|||||||
local function guardForTypos(name, map)
|
local function guardForTypos(name, map)
|
||||||
strict(name, map)
|
strict(name, map)
|
||||||
|
|
||||||
for key, child in pairs(map) do
|
for key, child in map do
|
||||||
if type(child) == "table" then
|
if type(child) == "table" then
|
||||||
guardForTypos(("%s.%s"):format(name, key), child)
|
guardForTypos(("%s.%s"):format(name, key), child)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ local encodePatchUpdate = require(script.Parent.encodePatchUpdate)
|
|||||||
return function(instanceMap, propertyChanges)
|
return function(instanceMap, propertyChanges)
|
||||||
local patch = PatchSet.newEmpty()
|
local patch = PatchSet.newEmpty()
|
||||||
|
|
||||||
for instance, properties in pairs(propertyChanges) do
|
for instance, properties in propertyChanges do
|
||||||
local instanceId = instanceMap.fromInstances[instance]
|
local instanceId = instanceMap.fromInstances[instance]
|
||||||
|
|
||||||
if instanceId == nil then
|
if instanceId == nil then
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ return function(instance, instanceId, properties)
|
|||||||
changedProperties = {},
|
changedProperties = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
for propertyName in pairs(properties) do
|
for propertyName in properties do
|
||||||
if propertyName == "Name" then
|
if propertyName == "Name" then
|
||||||
update.changedName = instance.Name
|
update.changedName = instance.Name
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ local function merge(...)
|
|||||||
local source = select(i, ...)
|
local source = select(i, ...)
|
||||||
|
|
||||||
if source ~= nil then
|
if source ~= nil then
|
||||||
for key, value in pairs(source) do
|
for key, value in source do
|
||||||
if value == None then
|
if value == None then
|
||||||
output[key] = nil
|
output[key] = nil
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function InstanceMap:__fmtDebug(output)
|
|||||||
-- Collect all of the entries in the InstanceMap and sort them by their
|
-- Collect all of the entries in the InstanceMap and sort them by their
|
||||||
-- label, which helps make our output deterministic.
|
-- label, which helps make our output deterministic.
|
||||||
local entries = {}
|
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)
|
local label = string.format("%s (%s)", instance:GetFullName(), instance.ClassName)
|
||||||
|
|
||||||
table.insert(entries, { id, label })
|
table.insert(entries, { id, label })
|
||||||
@@ -73,7 +73,7 @@ function InstanceMap:__fmtDebug(output)
|
|||||||
return a[2] < b[2]
|
return a[2] < b[2]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for _, entry in ipairs(entries) do
|
for _, entry in entries do
|
||||||
output:writeLine("{}: {}", entry[1], entry[2])
|
output:writeLine("{}: {}", entry[1], entry[2])
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ function InstanceMap:__disconnectSignals(instance)
|
|||||||
-- around the extra table. ValueBase objects force us to use multiple
|
-- around the extra table. ValueBase objects force us to use multiple
|
||||||
-- signals to emulate the Instance.Changed event, however.
|
-- signals to emulate the Instance.Changed event, however.
|
||||||
if typeof(signals) == "table" then
|
if typeof(signals) == "table" then
|
||||||
for _, signal in ipairs(signals) do
|
for _, signal in signals do
|
||||||
signal:Disconnect()
|
signal:Disconnect()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ local function trueEquals(a, b): boolean
|
|||||||
-- For tables, try recursive deep equality
|
-- For tables, try recursive deep equality
|
||||||
if typeA == "table" and typeB == "table" then
|
if typeA == "table" and typeB == "table" then
|
||||||
local checkedKeys = {}
|
local checkedKeys = {}
|
||||||
for key, value in pairs(a) do
|
for key, value in a do
|
||||||
checkedKeys[key] = true
|
checkedKeys[key] = true
|
||||||
if not trueEquals(value, b[key]) then
|
if not trueEquals(value, b[key]) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for key, value in pairs(b) do
|
for key, value in b do
|
||||||
if checkedKeys[key] then
|
if checkedKeys[key] then
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ return function()
|
|||||||
local function size(dict)
|
local function size(dict)
|
||||||
local len = 0
|
local len = 0
|
||||||
|
|
||||||
for _ in pairs(dict) do
|
for _ in dict do
|
||||||
len = len + 1
|
len = len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ local function hydrate(instanceMap, virtualInstances, rootId, rootInstance)
|
|||||||
for _, childId in ipairs(virtualInstance.Children) do
|
for _, childId in ipairs(virtualInstance.Children) do
|
||||||
local virtualChild = virtualInstances[childId]
|
local virtualChild = virtualInstances[childId]
|
||||||
|
|
||||||
for childIndex, childInstance in ipairs(existingChildren) do
|
for childIndex, childInstance in existingChildren do
|
||||||
if not isExistingChildVisited[childIndex] then
|
if not isExistingChildVisited[childIndex] then
|
||||||
-- We guard accessing Name and ClassName in order to avoid
|
-- We guard accessing Name and ClassName in order to avoid
|
||||||
-- tripping over children of DataModel that Rojo won't have
|
-- tripping over children of DataModel that Rojo won't have
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ function applyDeferredRefs(instanceMap, deferredRefs, unappliedPatch)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, entry in ipairs(deferredRefs) do
|
for _, entry in deferredRefs do
|
||||||
local _, refId = next(entry.virtualValue)
|
local _, refId = next(entry.virtualValue)
|
||||||
|
|
||||||
if refId == nil then
|
if refId == nil then
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ return function()
|
|||||||
local function size(dict)
|
local function size(dict)
|
||||||
local len = 0
|
local len = 0
|
||||||
|
|
||||||
for _ in pairs(dict) do
|
for _ in dict do
|
||||||
len = len + 1
|
len = len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ local gatherAssetUrlsRecursive
|
|||||||
function gatherAssetUrlsRecursive(currentTable, currentUrls)
|
function gatherAssetUrlsRecursive(currentTable, currentUrls)
|
||||||
currentUrls = currentUrls or {}
|
currentUrls = currentUrls or {}
|
||||||
|
|
||||||
for _, value in pairs(currentTable) do
|
for _, value in currentTable do
|
||||||
if typeof(value) == "string" then
|
if typeof(value) == "string" then
|
||||||
table.insert(currentUrls, value)
|
table.insert(currentUrls, value)
|
||||||
elseif typeof(value) == "table" then
|
elseif typeof(value) == "table" then
|
||||||
|
|||||||
Reference in New Issue
Block a user