From 7e0aa0b417b19c03bc2add438323d4e937de0fe1 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Mon, 4 Feb 2013 16:04:50 -0800 Subject: Fix performance problem in side by side viewer Inserting "\n" doesn't work. Prettify leaves the but often inserts a tag between and \n leaving a very deep tag stack for the DOM to handle. This is really slow to render and can cause mis-rendering. Insert a space before LF. Most prettify styles will treat this as the same as the LF, allowing the trailing space to be removed before splitting by line. Change-Id: I85d12c590a8d1bda1b1b66874a0dddb4628a8655 --- .../main/java/com/google/gerrit/prettify/common/PrettyFormatter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gerrit-prettify') diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java index 56bd723d93..511b056c86 100644 --- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java +++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java @@ -145,9 +145,9 @@ public abstract class PrettyFormatter implements SparseHtmlFile { // Drop any '\r' to avoid this problem. html = html.replace("\r\n", "\n"); - html = html.replace("\n", "\n"); + html = html.replace("\n", " \n"); html = prettify(html, getFileType()); - html = html.replace("\n", "\n"); + html = html.replace(" \n", "\n"); } else { html = expandTabs(html); } -- cgit v1.2.3