From a29fa8b51a167102d807330ce0c65d015e5c44e3 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Sun, 19 Mar 2017 20:04:08 -0400 Subject: performance tweak: cache hashes in memory --- stage1/resolver.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'stage1') diff --git a/stage1/resolver.scala b/stage1/resolver.scala index 4f6a2ef..866105e 100644 --- a/stage1/resolver.scala +++ b/stage1/resolver.scala @@ -286,10 +286,15 @@ case class BoundMavenDependency( } private def resolveHash(suffix: String, useClassifier: Boolean) = { - Files.readAllLines( - resolve( suffix ++ ".sha1", None, useClassifier ).toPath, - StandardCharsets.UTF_8 - ).mkString("\n").split(" ").head.trim + val path = resolve( suffix ++ ".sha1", None, useClassifier ).toPath + Option( classLoaderCache.hashMap.get("hash:"+path) ).map(_.asInstanceOf[String]).getOrElse{ + val result = Files.readAllLines( + path, + StandardCharsets.UTF_8 + ).mkString("\n").split(" ").head.trim + classLoaderCache.hashMap.put("hash:"+path, result) + result + } } def jarSha1: String = taskCache[BoundMavenDependency]("jarSha1").memoize{ resolveHash("jar", true) } -- cgit v1.2.3