-
Notifications
You must be signed in to change notification settings - Fork 91
Reduce memory footprint of Node classes
#2790
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
Open
KuechA
wants to merge
14
commits into
main
Choose a base branch
from
ak/slim-expr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ef8b7e1
Extract HasLocal from Expression
KuechA 6becfb3
Fix
KuechA 6418d93
Optimized EdgeList and EdgeSet implementation for single-item edges
KuechA 9deb412
Fix frontends
KuechA 3297523
Extract duplicate code
KuechA c3bf414
Changed mirroring
KuechA 096cfd9
Lazy assumptions and additionalProblems
KuechA d0c2808
Some changes in Name class
KuechA 2501c1c
Reuse name as code in Reference
KuechA d90bdf4
Fix llvm tests
KuechA 530b278
Identity checks in edges
KuechA 7f452fc
Fix another test
KuechA 22cbd59
Fix tests
KuechA 70c483b
Merge branch 'main' into ak/slim-expr
KuechA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,8 +69,16 @@ class Name( | |
| * this is basically a cache for [toString]. Otherwise, we would need to call [toString] a lot | ||
| * of times, to implement the necessary functions for [CharSequence]. | ||
| */ | ||
| private val fullName: String by lazy { | ||
| (if (parent != null) parent.toString() + delimiter else "") + localName | ||
| private var qualifiedFullNameCache: String? = null | ||
|
|
||
| private fun fullName(): String { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this a function now instead of a property? that changes things on many places in the code unnecessary and might even impact serialization. Can't you just use |
||
| // Most names are unqualified, so avoid any extra cache object/value in this hot case. | ||
| if (parent == null) { | ||
| return localName | ||
| } | ||
|
|
||
| return qualifiedFullNameCache | ||
| ?: (parent.toString() + delimiter + localName).also { qualifiedFullNameCache = it } | ||
| } | ||
|
|
||
| public override fun clone(): Name = Name(localName, parent?.clone(), delimiter) | ||
|
|
@@ -93,13 +101,14 @@ class Name( | |
| * Returns the string representation of this name using a fully qualified name notation with the | ||
| * specified [delimiter]. | ||
| */ | ||
| override fun toString() = fullName | ||
| override fun toString() = fullName() | ||
|
|
||
| override val length = fullName.length | ||
| override val length: Int | ||
| get() = fullName().length | ||
|
|
||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) return true | ||
| if (other is String) return this.fullName == other | ||
| if (other is String) return this.toString() == other | ||
| if (other is Name) | ||
| return localName == other.localName && | ||
| parent == other.parent && | ||
|
|
@@ -108,12 +117,12 @@ class Name( | |
| return false | ||
| } | ||
|
|
||
| override fun get(index: Int) = fullName[index] | ||
| override fun get(index: Int) = fullName()[index] | ||
|
|
||
| override fun hashCode() = Objects.hash(localName, parent, delimiter) | ||
|
|
||
| override fun subSequence(startIndex: Int, endIndex: Int): CharSequence = | ||
| fullName.subSequence(startIndex, endIndex) | ||
| fullName().subSequence(startIndex, endIndex) | ||
|
|
||
| /** | ||
| * Determines if this name ends with the [ending] (i.e., the localNames match until the [ending] | ||
|
|
@@ -141,7 +150,7 @@ class Name( | |
| Name(localName.replace(oldValue, newValue), parent, delimiter) | ||
|
|
||
| /** Compare names according to the string representation of the [fullName]. */ | ||
| override fun compareTo(other: Name) = fullName.compareTo(other.toString()) | ||
| override fun compareTo(other: Name) = toString().compareTo(other.toString()) | ||
|
|
||
| /** | ||
| * A name can be considered as "qualified", if it has any specified [parent]. Otherwise, only | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs kdoc