zinc
zinc copied to clipboard
Could apiHash be computed as an unordered hash of the name hashes?
val apiHash: HashAPI.Hash = HashAPI(classApi)
val nameHashes = (new xsbt.api.NameHashing(options.useOptimizedSealed())).nameHashes(classApi)
classApi.definitionType match {
case d @ (DefinitionType.ClassDef | DefinitionType.Trait) =>
val extraApiHash = {
if (d != DefinitionType.Trait) apiHash
else HashAPI(_.hashAPI(classApi), includePrivateDefsInTrait = true)
}
classApis(className) = ApiInfo(apiHash, extraApiHash, savedClassApi)
classPublicNameHashes(className) = nameHashes.toArray
case DefinitionType.Module | DefinitionType.PackageModule =>
objectApis(className) = ApiInfo(apiHash, apiHash, savedClassApi)
objectPublicNameHashes(className) = nameHashes.toArray
Now that name hashing is aways enabled, could we just redefine apiHash as f(nameHashes)? This would save about 10% of of the work in extract-api phase.
Another implementation strategy would be to change hashDefinition to cache its result on the Definition that it hashes, so the subesquent call will avoid the work.