tuned -- use Multi_Map;
authorwenzelm
Mon, 12 Aug 2013 13:32:26 +0200
changeset 52976 c3d82d58beaf
parent 52975 457c006f91bb
child 52977 15254e32d299
tuned -- use Multi_Map;
src/Pure/PIDE/document.scala
--- a/src/Pure/PIDE/document.scala	Mon Aug 12 13:30:54 2013 +0200
+++ b/src/Pure/PIDE/document.scala	Mon Aug 12 13:32:26 2013 +0200
@@ -62,43 +62,25 @@
 
     /* overlays -- print functions with arguments */
 
-    type Overlay = (Command, (String, List[String]))
+    type Print_Function = (String, List[String])
 
     object Overlays
     {
-      val empty = new Overlays(Map.empty)
+      val empty = new Overlays(Multi_Map.empty)
     }
 
-    final class Overlays private(rep: Map[Command, List[(String, List[String])]])
+    final class Overlays private(rep: Multi_Map[Command, Print_Function])
     {
       def commands: Set[Command] = rep.keySet
       def is_empty: Boolean = rep.isEmpty
 
-      def insert(cmd: Command, over: (String, List[String])): Overlays =
-      {
-        val overs = rep.getOrElse(cmd, Nil)
-        if (overs.contains(over)) this
-        else new Overlays(rep + (cmd -> (over :: overs)))
-      }
+      def insert(cmd: Command, over: Print_Function): Overlays =
+        new Overlays(rep.insert(cmd, over))
 
-      def remove(cmd: Command, over: (String, List[String])): Overlays =
-        rep.get(cmd) match {
-          case Some(overs) =>
-            if (overs.contains(over)) {
-              overs.filterNot(_ == over) match {
-                case Nil => new Overlays(rep - cmd)
-                case overs1 => new Overlays(rep + (cmd -> overs1))
-              }
-            }
-            else this
-          case None => this
-        }
+      def remove(cmd: Command, over: Print_Function): Overlays =
+        new Overlays(rep.remove(cmd, over))
 
-      def dest: List[Overlay] =
-        (for {
-          (cmd, overs) <- rep.iterator
-          over <- overs
-        } yield (cmd, over)).toList
+      def dest: List[(Command, Print_Function)] = rep.iterator.toList
     }