Changeset 7087


Ignore:
Timestamp:
11/15/16 20:54:14 (8 years ago)
Author:
Oliver Schonefeld
Message:
  • push pre-allocation of char buffer further up (now, only one buffer is allocated for each parse)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/parser/QueryParser.java

    r7086 r7087  
    197197            extends FCSParserBaseVisitor<Void> {
    198198        private final Deque<Object> stack;
     199        /*
     200         * pre-allocate buffer to store chars returned by Character.toChars in
     201         * unescapeString()
     202         */
     203        private final char[] buf = new char[2];
    199204
    200205
     
    592597            /* process escape sequences, if present */
    593598            if (regex.indexOf('\\') != -1) {
    594                 regex = unescapeString(regex);
     599                regex = unescapeString(regex, buf);
    595600            }
    596601
     
    798803
    799804
    800     private static String unescapeString(String s) {
    801         /*
    802          * buffer to store chars by Character.toChars; pre-allocate to avoid
    803          * allocation for every codepoint.
    804          */
    805         final char[] buf = new char[2];
    806 
     805    private static String unescapeString(String s, char[] buf) {
    807806        final StringBuilder sb = new StringBuilder();
    808807        for (int i = 0; i < s.length(); i++) {
Note: See TracChangeset for help on using the changeset viewer.