DESCRIPTION

SPY-127: Optimize StringUtils performance.

This changeset optimizes the individual StringUtils methods, especially
the isJsonObject method. Before, if no proper JSON was detected, a final
check against an Integer was performed. If no integer was found, a very
expensive exception was thrown, killing performance.

This check has been replaced with a faster regex. Also, other parts
of the methods have been refactored to be more performant.

Change-Id: I7616d2b042896aa76d73d536a3dde1c998990d9b


COMMENTS

author: Natasha Sullivan
date: 2014-03-05 13:18:24.972000000

Uploaded patch set 1.

-------------------------------------
author: Natasha Sullivan
date: 2014-03-05 13:22:10.547000000

Patch Set 1: Verified+1

-------------------------------------
author: Andreas Short
date: 2014-03-06 06:41:07.184000000

Patch Set 1: Code-Review+2

(2 comments)

Line:72, src/test/java/net/spy/memcached/util/StringUtilsTest.java -> might be nice to have some tougher things in there.  like, leave off a curly, or have an extra or missing comma

Line:81, src/test/java/net/spy/memcached/util/StringUtilsTest.java -> nitpick: might be nice to comment you're checking for an exception here.

-------------------------------------
author: Natasha Sullivan
date: 2014-03-06 07:00:38.822000000

Patch Set 1:

(2 comments)

Line:72, src/test/java/net/spy/memcached/util/StringUtilsTest.java -> Oh, you are hitting a tough spot here. If you check the old impl, stuff like this was never caught. 

I know there are some fancy regex out there to check for proper JSON, but this would not be backwards compatible with the current approach. It just checks for startsWith.

I refrained from changing the behaviour because of our previous discussion on the Query refactoring.

Line:81, src/test/java/net/spy/memcached/util/StringUtilsTest.java -> hmm I dont want an exception here?
The problem is that validateKey returns void, so there is nothing I can assert against.

If all is good the true(true) hits, if an exception is raised inside the method it will fail. Or maybe I misunderstood you?

-------------------------------------
