This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Allocate only one Label per tag type, and only one default Label.#2
Open
thatfulvioguy wants to merge 1 commit intoSystemFw:masterfrom
Open
Allocate only one Label per tag type, and only one default Label.#2thatfulvioguy wants to merge 1 commit intoSystemFw:masterfrom
thatfulvioguy wants to merge 1 commit intoSystemFw:masterfrom
Conversation
Owner
|
Did you notice this as an actual bottleneck or just a nice to have? |
Author
|
Yeah, it's a nice-to-have. However, I've just made it work using a Manifest instead: private def nameOf[A](implicit m: Manifest[A]) = {
val typeName = m.toString
typeName.substring(0, typeName.lastIndexOf(".type"))
}
trait MakeLabel { self =>
// See eidos.id.Format.UUID for an explanation of this
// format: off
final def `"In Eidos, you can only extend one of MakeLabel or CustomLabel"`
: LabelDefinitionConflict = null
implicit final val l: Label[this.type] = new Label[this.type] {
val label: String = nameOf[self.type]
}
}With that, it should be possible to remove the case requirement entirely. Is that something you'd like? |
Owner
|
Manifest uses reflection though, which means you are getting back a possibly larger perf penalty for that, I think |
Author
|
The manifest is only created once when the tag object and its label are constructed |
1aed2bb to
df4cbac
Compare
Author
|
That's the Manifest version pushed. Should I continue with relaxing the case object requirement? |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I was looking at potential memory optimisations in an application and noticed that currently, a new Label is created for each Id. This can be avoided by:
though this comes at the cost of a self type error when attempting to use a non-case object as a tag.