Skip to content

Commit

Permalink
Reduce footprint by interning stringified Names in Analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed Aug 19, 2020
1 parent bd777f8 commit 8d49d9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class ExtractUsedNames[GlobalType <: CallbackGlobal](val global: GlobalType)

// Handle names circumscribed to classes
traverser.usedNamesFromClasses.foreach { (rawClassName, usedNames) =>
val className = rawClassName.toString.trim
val className = rawClassName.toString.trim.intern()
usedNames.defaultNames.foreach { rawUsedName =>
val useName = rawUsedName.decoded.trim
val useName = rawUsedName.decoded.trim.intern()
val existingScopes = usedNames.scopedNames.get(rawUsedName)
val useScopes = {
if (existingScopes == null) DefaultScopes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)

def fromAnnotation(annotation: Schema.Annotation): Annotation = {
def fromAnnotationArgument(argument: Schema.AnnotationArgument): AnnotationArgument = {
val name = argument.getName
val name = argument.getName.intern()
val value = argument.getValue
AnnotationArgument.of(name, value)
}
Expand Down Expand Up @@ -454,7 +454,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
ExpectedUpperBoundInTypeDeclaration
}

val name = classDefinition.getName
val name = classDefinition.getName.intern()
val access =
if (classDefinition.hasAccess) fromAccess(classDefinition.getAccess)
else MissingAccessInDef.!!
Expand All @@ -474,7 +474,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
ReadersFeedback.UnrecognizedParamModifier.!!
}
}
val name = methodParameter.getName
val name = methodParameter.getName.intern()
val hasDefault = methodParameter.getHasDefault
val `type` =
if (methodParameter.hasType) fromType(methodParameter.getType)
Expand Down Expand Up @@ -575,7 +575,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
def fromClassLike(classLike: Schema.ClassLike): ClassLike = {
def expectedMsg(msg: String) = ReadersFeedback.expected(msg, Classes.ClassLike)
def expected(clazz: Class[_]) = expectedMsg(clazz.getName)
val name = classLike.getName
val name = classLike.getName.intern()
val access =
if (classLike.hasAccess) fromAccess(classLike.getAccess)
else expected(Classes.Access).!!
Expand Down Expand Up @@ -636,7 +636,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
}

def fromNameHash(nameHash: Schema.NameHash): NameHash = {
val name = nameHash.getName
val name = nameHash.getName.intern()
val hash = nameHash.getHash
val scope = fromUseScope(nameHash.getScope, nameHash.getScopeValue)
NameHash.of(name, scope, hash)
Expand All @@ -645,7 +645,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
import SafeLazyProxy.{ strict => mkLazy }
import ReadersFeedback.ExpectedCompanionsInAnalyzedClass
val compilationTs = analyzedClass.getCompilationTimestamp
val name = analyzedClass.getName
val name = analyzedClass.getName.intern()
val api =
if (!shouldStoreApis) EmptyLazyCompanions
else
Expand Down Expand Up @@ -692,7 +692,7 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
}

def fromUsedName(usedName: Schema.UsedName): UsedName = {
val name = usedName.getName
val name = usedName.getName.intern()
val useScopes = util.EnumSet.noneOf(classOf[UseScope])
val len = usedName.getScopesCount
val scopes = for {
Expand Down

0 comments on commit 8d49d9c

Please sign in to comment.