Do not compute name hashes when name hashing is disabled

We should compute name hashes only when name hashing is enabled.
Otherwise, we just store an empty value for name hashes.
This commit is contained in:
Grzegorz Kossakowski 2014-01-08 22:50:54 +01:00 committed by Mark Harrah
parent b9489c6035
commit dcb327e6f4
1 changed files with 9 additions and 1 deletions

View File

@ -146,10 +146,18 @@ private final class AnalysisCallback(internalMap: File => Option[File], external
classToSource.put(module, source)
}
// empty value used when name hashing algorithm is disabled
private val emptyNameHashes = new xsbti.api._internalOnly_NameHashes(Array.empty, Array.empty)
def api(sourceFile: File, source: SourceAPI) {
import xsbt.api.{APIUtil, HashAPI}
if (APIUtil.isScalaSourceName(sourceFile.getName) && APIUtil.hasMacro(source)) macroSources += sourceFile
publicNameHashes(sourceFile) = (new NameHashing).nameHashes(source)
publicNameHashes(sourceFile) = {
if (nameHashing)
(new NameHashing).nameHashes(source)
else
emptyNameHashes
}
val shouldMinimize = !Incremental.apiDebug(options)
val savedSource = if (shouldMinimize) APIUtil.minimize(source) else source
apis(sourceFile) = (HashAPI(source), savedSource)