Skip to content
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

Could apiHash be computed as an unordered hash of the name hashes? #775

Open
retronym opened this issue May 2, 2020 · 2 comments
Open
Milestone

Comments

@retronym
Copy link
Member

retronym commented May 2, 2020

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.

@retronym retronym added this to the 1.4.0 milestone May 2, 2020
@retronym
Copy link
Member Author

retronym commented May 2, 2020

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.

@retronym
Copy link
Member Author

retronym commented May 2, 2020

image

@eed3si9n eed3si9n modified the milestones: 1.4.0, 1.4.1 Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants