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

Found a large 15 second parse function #7659

Open
1 task done
TheLimeGlass opened this issue Mar 1, 2025 · 3 comments
Open
1 task done

Found a large 15 second parse function #7659

TheLimeGlass opened this issue Mar 1, 2025 · 3 comments

Comments

@TheLimeGlass
Copy link
Contributor

Skript/Server Version

[10:42:46 INFO]: [Skript] Server Version: 1.21.4-144-edacfdf (MC: 1.21.4)
[10:42:46 INFO]: [Skript] Skript Version: 2.10.1 (selfbuilt-unknown)
[10:42:46 INFO]: [Skript]  - skript-reflect v2.6 (https://github.com/SkriptLang/skript-reflect)
[10:42:46 INFO]: [Skript] Installed dependencies:
[10:42:46 INFO]: [Skript]  - WorldGuard v7.0.13-beta-2+5c4848b

Bug Description

function getCuboid(location: location, tier: string) :: locations:
	set {_size} to {data::%{_tier}%::size}
	set {_x} to x-coord of {_location}
	set {_z} to z-coord of {_location}
	set {_min} to location({_x} - {_size}, -50, {_z} - {_size}, world of {_location})
	set {_max} to location({_x} + {_size}, y-coord of {_location} + {data::%{_tier}%::height}, {_z} + {_size}, world of {_location})
	return {_min} and {_max}

This function parsing time adds 15 seconds to the parsing.

Expected Behavior

Something about the location function plus adding all the coordinates makes the parser take longer than it should here.

Steps to Reproduce

paste function, and reload script

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@3meraldK
Copy link
Contributor

3meraldK commented Mar 2, 2025

If you want a solution, simply replacing the expression y-coord of {_location} + {data::%{_tier}%::height} with a new variable will reduce parse time by 3/4. It's a good practice to replace complex (not-so-complex here) expressions with variables to decrease parse times.

@Fusezion
Copy link
Contributor

Fusezion commented Mar 3, 2025

I mean this wasn't anything new, it's been around for ages and the solutions have always been split it up or use (), there's no solution viable really

@erenkarakal
Copy link
Member

even with a full parser rewrite I am not sure if this is possible to fix since Skript has English syntax. I would like to be proven wrong though.

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

No branches or pull requests

4 participants