If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.
There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's cachedMembers.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/915
**Author:** [@bioball](https://github.com/bioball)
**Created:** 1/29/2025
**Status:** ✅ Merged
**Merged:** 1/29/2025
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `const-member-optimization`
---
### 📝 Commits (1)
- [`5bd4ef5`](https://github.com/apple/pkl/commit/5bd4ef5ad13815d58e947772d558c781843f2a92) Optimization: execute const object bodies and typechecks only once
### 📊 Changes
**3 files changed** (+37 additions, -0 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java` (+12 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/basic/constModifier5.pkl` (+13 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/basic/constModifier5.err` (+12 -0)
</details>
### 📄 Description
Closes https://github.com/apple/pkl/issues/508
If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.
There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's `cachedMembers`.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/915
Author: @bioball
Created: 1/29/2025
Status: ✅ Merged
Merged: 1/29/2025
Merged by: @bioball
Base:
main← Head:const-member-optimization📝 Commits (1)
5bd4ef5Optimization: execute const object bodies and typechecks only once📊 Changes
3 files changed (+37 additions, -0 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java(+12 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/basic/constModifier5.pkl(+13 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/basic/constModifier5.err(+12 -0)📄 Description
Closes https://github.com/apple/pkl/issues/508
If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.
There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's
cachedMembers.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.