Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allocate table #1633

Merged
merged 1 commit into from
Sep 2, 2024
Merged

allocate table #1633

merged 1 commit into from
Sep 2, 2024

Conversation

loveridge
Copy link
Collaborator

#1632

1.5 microseconds saved for an array of 30 items:
image

function widget:Update()
	local table = Spring.AllocateTable(30) -- vs {}
	for i = 1, 30, 1 do
		table[i] = i
	end
	Spring.Echo(table[25])
end

Copy link
Collaborator

@sprunk sprunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be accessible from synced (so not in UnsyncedCtrl)

@loveridge
Copy link
Collaborator Author

Should be accessible from synced (so not in UnsyncedCtrl)

The Synced environment registers UnsyncedCtrl functions, and can call them.

if not gadgetHandler:IsSyncedCode() then return end

function gadget:GetInfo()
	return {
		name    = "Test Gadget",
		desc    = "",
		enabled = true
	}
end

local t = Spring.AllocateTable(30)
t[3] = 4
Spring.Echo("ALLOCATE", t[3])

Worked fine

Copy link
Collaborator

@sprunk sprunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

@lhog lhog merged commit 432f997 into beyond-all-reason:master Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants