From a00e65cb1f14f048db93b594da7ed0de22a1d353 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 5 Aug 2014 17:43:31 +1000 Subject: [PATCH] optimised HttpFields fixes --- .../main/java/org/eclipse/jetty/http/HttpFields.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 0779a5ae6b1..393b6719f81 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -823,25 +823,30 @@ public class HttpFields implements Iterable private class Itr implements Iterator { int _cursor; // index of next element to return + int _last=-1; public boolean hasNext() { return _cursor != _size; } - @SuppressWarnings("unchecked") public HttpField next() { int i = _cursor; if (i >= _size) throw new NoSuchElementException(); _cursor = i + 1; - return _fields[i]; + return _fields[_last=i]; } public void remove() { - throw new UnsupportedOperationException(); + if (_last<0) + throw new IllegalStateException(); + + System.arraycopy(_fields,_last+1,_fields,_last,--_size-_last); + _cursor=_last; + _last=-1; } }