use collectFirst instead of collect and headOption

This commit is contained in:
xuwei-k 2025-01-01 16:06:34 +09:00
parent 439e24fb84
commit 5438781142
2 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@ object Pkg:
.orElse(Some(default2010Timestamp)) .orElse(Some(default2010Timestamp))
def timeFromConfiguration(config: Configuration): Option[Long] = def timeFromConfiguration(config: Configuration): Option[Long] =
(config.options.collect { case t: PackageOption.FixedTimestamp => t }).headOption match config.options.collectFirst { case t: PackageOption.FixedTimestamp => t } match
case Some(PackageOption.FixedTimestamp(value)) => value case Some(PackageOption.FixedTimestamp(value)) => value
case _ => defaultTimestamp case _ => defaultTimestamp

View File

@ -14,9 +14,9 @@ object RemoteCachePlugin extends AutoPlugin:
val remoteOpt = remoteCache.value val remoteOpt = remoteCache.value
remoteOpt match remoteOpt match
case Some(remote) => case Some(remote) =>
val disk = orig.collect { case r: DiskActionCacheStore => val disk = orig.collectFirst { case r: DiskActionCacheStore =>
r r
}.headOption match } match
case Some(x) => x case Some(x) => x
case None => sys.error("disk store not found") case None => sys.error("disk store not found")
val r = GrpcActionCacheStore( val r = GrpcActionCacheStore(