From 4708c907c1f070ab573d361e29092a52c79374ae Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 23 Sep 2013 15:19:41 +1000 Subject: [PATCH] 417284 Precompiled regex in HttpField --- .../main/java/org/eclipse/jetty/http/HttpField.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java index 8241d1d62f4..9e261756522 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.http; import java.nio.ByteBuffer; import java.util.HashSet; import java.util.Set; +import java.util.regex.Pattern; import org.eclipse.jetty.util.ArrayTrie; import org.eclipse.jetty.util.BufferUtil; @@ -100,7 +101,8 @@ public class HttpField CACHE.put(new HttpField(HttpHeader.AUTHORIZATION,(String)null)); CACHE.put(new HttpField(HttpHeader.COOKIE,(String)null)); } - + + private final static Pattern __splitter = Pattern.compile("\\s*,\\s*"); private final static byte[] __colon_space = new byte[] {':',' '}; private final HttpHeader _header; @@ -153,10 +155,10 @@ public class HttpField if (value.equalsIgnoreCase(_value)) return true; - String[] split = _value.split("\\s*,\\s*"); - for (String s : split) + String[] split = __splitter.split(_value); + for (int i = 0; split!=null && i < split.length; i++) { - if (value.equalsIgnoreCase(s)) + if (value.equalsIgnoreCase(split[i])) return true; }