minor performance tuning;
authorwenzelm
Thu, 22 Feb 2024 20:05:24 +0100
changeset 79706 4f218e6e9d23
parent 79705 a6dc0d4ffea2
child 79707 4ded6d260db0
minor performance tuning;
src/Pure/ML/ml_heap.scala
--- a/src/Pure/ML/ml_heap.scala	Thu Feb 22 19:58:52 2024 +0100
+++ b/src/Pure/ML/ml_heap.scala	Thu Feb 22 20:05:24 2024 +0100
@@ -88,16 +88,18 @@
         name = "slices_size")
     }
 
-    def read_digests(db: SQL.Database, names: Iterable[String]): Map[String, SHA1.Digest] = {
-      db.execute_query_statement(
-        Base.table.select(List(Base.name, Base.heap_digest),
-          sql = Generic.name.where_member(names)),
-        List.from[(String, String)],
-        res => res.string(Base.name) -> res.string(Base.heap_digest)
-      ).collect({
-        case (name, digest) if digest.nonEmpty => name -> SHA1.fake_digest(digest)
-      }).toMap
-    }
+    def read_digests(db: SQL.Database, names: Iterable[String]): Map[String, SHA1.Digest] =
+      if (names.isEmpty) Map.empty
+      else {
+        db.execute_query_statement(
+          Base.table.select(List(Base.name, Base.heap_digest),
+            sql = Generic.name.where_member(names)),
+          List.from[(String, String)],
+          res => res.string(Base.name) -> res.string(Base.heap_digest)
+        ).collect({
+          case (name, digest) if digest.nonEmpty => name -> SHA1.fake_digest(digest)
+        }).toMap
+      }
 
     def read_slices(db: SQL.Database, name: String): List[Bytes] =
       db.execute_query_statement(