From 37f629765e236c430357202bfdf562f897072893 Mon Sep 17 00:00:00 2001 From: Marcos Nils Date: Fri, 17 Jan 2014 12:06:20 -0300 Subject: [PATCH] Improve performance in MOVED and ASK response parsing --- src/main/java/redis/clients/jedis/Protocol.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Protocol.java b/src/main/java/redis/clients/jedis/Protocol.java index fb9eb8c..a5e08c6 100644 --- a/src/main/java/redis/clients/jedis/Protocol.java +++ b/src/main/java/redis/clients/jedis/Protocol.java @@ -79,11 +79,10 @@ public final class Protocol { String message = is.readLine(); //TODO: I'm not sure if this is the best way to do this. //Maybe Read only first 5 bytes instead? - // - if (message.contains(MOVED_RESPONSE)) { + if (message.startsWith(MOVED_RESPONSE)) { String[] movedInfo = parseTargetHostAndSlot(message); throw new JedisMovedDataException(message, new HostAndPort(movedInfo[1], Integer.valueOf(movedInfo[2])), Integer.valueOf(movedInfo[0])); - } else if (message.contains(ASK_RESPONSE)) { + } else if (message.startsWith(ASK_RESPONSE)) { String[] askInfo = parseTargetHostAndSlot(message); throw new JedisAskDataException(message, new HostAndPort(askInfo[1], Integer.valueOf(askInfo[2])), Integer.valueOf(askInfo[0])); }