Line.Document consists of independently allocated strings;
authorwenzelm
Sat, 07 Jan 2017 16:16:41 +0100
changeset 64820 00488a8c042f
parent 64819 bebe7a164068
child 64821 37bf7acf6a4b
Line.Document consists of independently allocated strings; tuned signature;
src/Pure/PIDE/line.scala
src/Pure/PIDE/xml.scala
src/Pure/library.scala
--- a/src/Pure/PIDE/line.scala	Sat Jan 07 15:25:01 2017 +0100
+++ b/src/Pure/PIDE/line.scala	Sat Jan 07 16:16:41 2017 +0100
@@ -90,7 +90,7 @@
   object Document
   {
     def apply(text: String, text_length: Text.Length): Document =
-      Document(logical_lines(text).map(Line(_)), text_length)
+      Document(logical_lines(text).map(s => Line(Library.trim_substring(s))), text_length)
   }
 
   sealed case class Document(lines: List[Line], text_length: Text.Length)
--- a/src/Pure/PIDE/xml.scala	Sat Jan 07 15:25:01 2017 +0100
+++ b/src/Pure/PIDE/xml.scala	Sat Jan 07 16:16:41 2017 +0100
@@ -148,8 +148,6 @@
       x
     }
 
-    private def trim_bytes(s: String): String = new String(s.toCharArray)
-
     private def cache_string(x: String): String =
       if (x == "true") "true"
       else if (x == "false") "false"
@@ -159,7 +157,7 @@
         lookup(x) match {
           case Some(y) => y
           case None =>
-            val z = trim_bytes(x)
+            val z = Library.trim_substring(x)
             if (z.length > max_string) z else store(z)
         }
     private def cache_props(x: Properties.T): Properties.T =
@@ -167,7 +165,7 @@
       else
         lookup(x) match {
           case Some(y) => y
-          case None => store(x.map(p => (trim_bytes(p._1).intern, cache_string(p._2))))
+          case None => store(x.map(p => (Library.trim_substring(p._1).intern, cache_string(p._2))))
         }
     private def cache_markup(x: Markup): Markup =
       lookup(x) match {
--- a/src/Pure/library.scala	Sat Jan 07 15:25:01 2017 +0100
+++ b/src/Pure/library.scala	Sat Jan 07 16:16:41 2017 +0100
@@ -139,6 +139,8 @@
   def trim_split_lines(s: String): List[String] =
     split_lines(trim_line(s)).map(trim_line(_))
 
+  def trim_substring(s: String): String = new String(s.toCharArray)
+
 
   /* quote */