Repository navigation
Conversation
The profile was run (dofile) before Find, Layer, Attribute and the other functions were set as globals, so a profile could not keep them in locals at its top. They are now registered before the profile is loaded, and again afterwards, so that they still replace profile functions of the same name, as before. CONFIGURATION.md mentions the locals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gain: a profile can keep tilemaker's functions in locals at its top (
local Find, Holds, Layer = Find, Holds, Layer), which Lua reaches faster than globals. Until now such a profile failed with a Lua runtime error, because the functions were registered only after the profile had been loaded. Output is unchanged; I haven't timed how much the locals save, as that depends on the profile.Follow-up to @cldellow's first question on #993, kept separate from it as promised there.
What
OsmLuaProcessing's constructor randofileon the profile first and then setFind,Layer,Attributeand the rest as Lua globals. The registrations move into a helper,registerLuaFunctions, which now runs beforedofile.dofile, so a function the profile defines with the same name as one of tilemaker's is still replaced by tilemaker's, as before. Without this, such a function (dead code until now) would suddenly take effect. The helper is cheap, and it runs once per thread when the Lua state is set up.init_function, on keeping the functions in locals.Output
Unchanged for any profile that worked before.
Verification
Linux, GCC 14, Boost 1.83, Lua 5.4, four extracts (Lake Huron, Canberra, Patagonia, Canary Islands), bundled profile, OpenMapTiles config without shapefile layers. Variants: master; this PR; this PR with a line of 13 locals at the top of the profile (
local Find, Holds, Layer, … = Find, Holds, Layer, …); this PR with the profile's ownArea()andLayer()appended.pairs()inGetPOIRank), so a second master run is the control. Every variant differs from master only in thepoilayer and by as much as master's own rerun (Canberra 118 tiles for master's rerun vs 129-151 for the variants, Canary 525 vs 529-568, Patagonia 209 vs 127-156). No other layer differs in any tile.🤖 Generated with Claude Code