Explorar o código

Pre-alloc EReg objects in HtmlText (#372)

Pascal Peridont %!s(int64=7) %!d(string=hai) anos
pai
achega
402afa5b27
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      h2d/HtmlText.hx

+ 4 - 2
h2d/HtmlText.hx

@@ -110,9 +110,11 @@ class HtmlText extends Text {
 		}
 	}
 
+	static var REG_SPACES = ~/[\r\n\t ]+/g;
+	static var REG_HTMLENTITIES = ~/&([A-Za-z]+);/g;
 	function htmlToText( t : hxd.UString )  {
-		t = ~/[\r\n\t ]+/g.replace(t, " ");
-		t = ~/&([A-Za-z]+);/g.map(t, function(r) {
+		t = REG_SPACES.replace(t, " ");
+		t = REG_HTMLENTITIES.map(t, function(r) {
 			switch( r.matched(1).toLowerCase() ) {
 			case "lt": return "<";
 			case "gt": return ">";