[ https://issues.apache.org/jira/browse/LUCENE-1497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12662004#action_12662004 ]
Shai Erera commented on LUCENE-1497: ------------------------------------ If I understand you correctly, you propose to change the code to: preTag + originalText + postTag. That creates 2 (or 3) StringBuffers actually. Java implements + by allocating a StringBuffer and appending both Strings to it. What I propose is to create the StringBuffer large enough from the beginning such that there won't be additional allocations. > Minor changes to SimpleHTMLFormatter > ------------------------------------ > > Key: LUCENE-1497 > URL: https://issues.apache.org/jira/browse/LUCENE-1497 > Project: Lucene - Java > Issue Type: Improvement > Components: contrib/highlighter > Reporter: Shai Erera > Assignee: Michael McCandless > Priority: Minor > Fix For: 2.4.1, 2.9 > > Attachments: LUCENE-1497.patch > > > I'd like to make few minor changes to SimpleHTMLFormatter. > 1. Define DEFAULT_PRE_TAG and DEFAULT_POST_TAG and use them in the default > constructor. This will not trigger String lookups by the JVM whenever the > highlighter is instantiated. > 2. Create the StringBuffer in highlightTerm with the right number of > characters from the beginning. Even though StringBuffer's default constructor > allocates 16 chars, which will probably be enough for most highlighted terms > (pre + post tags are 7 chars, which leaves 9 chars for terms), I think it's > better to allocate SB with the right # of chars in advance, to avoid char[] > allocations in the middle. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org