tuned -- avoid copy of empty value;
authorwenzelm
Thu, 23 Feb 2012 19:35:05 +0100
changeset 46623 bce24d3f29e7
parent 46622 3ccecb301d4e
child 46624 dc4c72092088
tuned -- avoid copy of empty value;
src/Pure/General/graph.scala
--- a/src/Pure/General/graph.scala	Thu Feb 23 19:34:48 2012 +0100
+++ b/src/Pure/General/graph.scala	Thu Feb 23 19:35:05 2012 +0100
@@ -17,7 +17,8 @@
   class Undefined[Key](x: Key) extends Exception
   class Cycles[Key](cycles: List[List[Key]]) extends Exception
 
-  def empty[Key, A]: Graph[Key, A] = new Graph[Key, A](Map.empty)
+  private val empty_val: Graph[Any, Nothing] = new Graph[Any, Nothing](Map.empty)
+  def empty[Key, A]: Graph[Key, A] = empty_val.asInstanceOf[Graph[Key, A]]
 }