Skip to content

Commit

Permalink
Optimize tag application (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoFlection Bot committed Jun 13, 2024
1 parent 6cc90ea commit 060fd2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion foreman.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tools]
rotrieve = { source = "Roblox/rotriever", version = "=0.5.13-alpha.2" }
rotrieve = { source = "Roblox/rotriever", version = "=0.5.13-alpha.4" }
rojo = { source = "Roblox/rojo-rbx-rojo", version = "7.2.1" }
selene = { source = "Roblox/Kampfkarren-selene", version = "=0.21.1" }
stylua = { source = "Roblox/JohnnyMorganz-StyLua", version = "=0.15.1" }
Expand Down
18 changes: 12 additions & 6 deletions modules/react-roblox/src/client/roblox/RobloxComponentProps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,22 @@ local function applyTags(hostInstance: Instance, oldTags: string?, newTags: stri
end
end

local oldTagSet = Set.new(String.split(oldTags or "", " "))
local newTagSet = Set.new(String.split(newTags or "", " "))
local oldTagSet = {}
for str in string.gmatch(oldTags or "", "%S+") do
oldTagSet[str] = true
end
local newTagSet = {}
for str in string.gmatch(newTags or "", "%S+") do
newTagSet[str] = true
end

for _, tag in oldTagSet do
if not newTagSet:has(tag) then
for tag, _ in oldTagSet do
if not newTagSet[tag] then
CollectionService:RemoveTag(hostInstance, tag)
end
end
for _, tag in newTagSet do
if not oldTagSet:has(tag) then
for tag, _ in newTagSet do
if not oldTagSet[tag] then
CollectionService:AddTag(hostInstance, tag)
end
end
Expand Down
2 changes: 1 addition & 1 deletion rotriever.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
version = "17.0.3"
version = "17.0.4"
members = ["modules/*"]
authors = [
"Paul Doyle <[email protected]>",
Expand Down

0 comments on commit 060fd2e

Please sign in to comment.