Skip to content

Conversation

shanecelis
Copy link
Contributor

Congrats on getting 0.14.0 and 0.15.0 releases out! Very exciting.

Summary

I removed the asset_path field from ScriptAsset and altered the script_asset:asset_path() code to use the path present in the handle or use the path given by the AssetServer based on the handle. This preserves the prior behavior and the tests pass.

Why?

I feel like the asset path is not a property of the asset. It's a property of the handle to the asset, which may or may not have an AssetPath.

The asset to me is like the contents of a file. Some files may declare what they believe their file path to be—and they can be wrong; most files don't. The file's path is an external concern likewise for an asset path.

Also I worry that having the AssetPath as a field invites confusion. I know you can summon a path with AssetPath::default() but that is effectively wrong or invalid. A field of Option<AssetPath> would be less prone to confusion, but I don't think it's warranted or necessary as evidenced by this implementation.

Another reason to prefer not having an AssetPath is there are many valid uses that do not have an asset path. Suppose an app uses a string given by the user at runtime to create a ScriptAsset. There is no asset path in that case. Procedurally generated cases have similar uses.

Alternatives

One could use Option<AssetPath> as the field to avoid forcing the user to provide a path or provide a default/invalid path.

Testing

I ran the tests. Found the script_asset:asset_path() test failing, which I believe that function is the reason the field exists. I changed its implementation to offer the same results as before but without the field.

Copy link

semanticdiff-com bot commented Aug 17, 2025

Copy link
Contributor

🐰 Bencher Report

Branchremove-asset-path-field
Testbedlinux-gha

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
component/access Lua📈 view plot
⚠️ NO THRESHOLD
3,432.00 ns
component/access Rhai📈 view plot
⚠️ NO THRESHOLD
5,293.50 ns
component/get Lua📈 view plot
⚠️ NO THRESHOLD
2,125.20 ns
component/get Rhai📈 view plot
⚠️ NO THRESHOLD
4,057.40 ns
conversions/Mut::from📈 view plot
⚠️ NO THRESHOLD
99.79 ns
conversions/Ref::from📈 view plot
⚠️ NO THRESHOLD
78.70 ns
conversions/ScriptValue::List📈 view plot
⚠️ NO THRESHOLD
263.98 ns
conversions/ScriptValue::Map📈 view plot
⚠️ NO THRESHOLD
1,164.40 ns
conversions/ScriptValue::Reference::from_into📈 view plot
⚠️ NO THRESHOLD
25.50 ns
conversions/Val::from_into📈 view plot
⚠️ NO THRESHOLD
261.48 ns
function/call 4 args Lua📈 view plot
⚠️ NO THRESHOLD
1,583.80 ns
function/call 4 args Rhai📈 view plot
⚠️ NO THRESHOLD
1,348.40 ns
function/call Lua📈 view plot
⚠️ NO THRESHOLD
228.75 ns
function/call Rhai📈 view plot
⚠️ NO THRESHOLD
454.47 ns
loading/empty Lua📈 view plot
⚠️ NO THRESHOLD
51,521.00 ns
loading/empty Rhai📈 view plot
⚠️ NO THRESHOLD
286,590.00 ns
math/vec mat ops Lua📈 view plot
⚠️ NO THRESHOLD
6,095.70 ns
math/vec mat ops Rhai📈 view plot
⚠️ NO THRESHOLD
5,967.10 ns
query/10 entities Lua📈 view plot
⚠️ NO THRESHOLD
18,745.00 ns
query/10 entities Rhai📈 view plot
⚠️ NO THRESHOLD
18,495.00 ns
query/100 entities Lua📈 view plot
⚠️ NO THRESHOLD
38,170.00 ns
query/100 entities Rhai📈 view plot
⚠️ NO THRESHOLD
28,181.00 ns
query/1000 entities Lua📈 view plot
⚠️ NO THRESHOLD
242,700.00 ns
query/1000 entities Rhai📈 view plot
⚠️ NO THRESHOLD
149,580.00 ns
reflection/10 Lua📈 view plot
⚠️ NO THRESHOLD
5,568.40 ns
reflection/10 Rhai📈 view plot
⚠️ NO THRESHOLD
15,192.00 ns
reflection/100 Lua📈 view plot
⚠️ NO THRESHOLD
47,806.00 ns
reflection/100 Rhai📈 view plot
⚠️ NO THRESHOLD
696,330.00 ns
resource/access Lua📈 view plot
⚠️ NO THRESHOLD
3,071.80 ns
resource/access Rhai📈 view plot
⚠️ NO THRESHOLD
4,829.40 ns
resource/get Lua📈 view plot
⚠️ NO THRESHOLD
1,757.60 ns
resource/get Rhai📈 view plot
⚠️ NO THRESHOLD
3,555.30 ns
🐰 View full continuous benchmarking report in Bencher

@makspll
Copy link
Owner

makspll commented Aug 18, 2025

Yeah that's valid

@makspll makspll changed the title chore: Remove asset_path field from ScriptAsset. changed: Remove asset_path field from ScriptAsset. Aug 18, 2025
@makspll makspll merged commit e946120 into makspll:main Aug 18, 2025
23 of 24 checks passed
This was referenced Aug 18, 2025
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.

2 participants