From dcb327e6f4dc0e5bc096bba691d059b991513bf4 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Wed, 8 Jan 2014 22:50:54 +0100 Subject: [PATCH] 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. --- compile/inc/src/main/scala/sbt/inc/Compile.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compile/inc/src/main/scala/sbt/inc/Compile.scala b/compile/inc/src/main/scala/sbt/inc/Compile.scala index edf714f06..925e8fd3d 100644 --- a/compile/inc/src/main/scala/sbt/inc/Compile.scala +++ b/compile/inc/src/main/scala/sbt/inc/Compile.scala @@ -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)