From 29fecf859fc94d3b1f35a3fb84ee6673b0653cfe Mon Sep 17 00:00:00 2001
From: Josh Baker <joshbaker77@gmail.com>
Date: Sun, 21 Aug 2016 10:10:55 -0700
Subject: [PATCH] minor performance optz

---
 gjson.go | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/gjson.go b/gjson.go
index 5cf2e31..8001db3 100644
--- a/gjson.go
+++ b/gjson.go
@@ -82,6 +82,9 @@ func (t Result) Exists() bool {
 //	nil, for JSON null
 //
 func (t Result) Value() interface{} {
+	if t.Type == String {
+		return t.Str
+	}
 	switch t.Type {
 	default:
 		return nil
@@ -89,8 +92,6 @@ func (t Result) Value() interface{} {
 		return false
 	case Number:
 		return t.Num
-	case String:
-		return t.Str
 	case Multi:
 		var res = make([]interface{}, len(t.Multi))
 		for i, v := range t.Multi {
@@ -697,15 +698,16 @@ func (t Result) Less(token Result, caseSensitive bool) bool {
 	if t.Type > token.Type {
 		return false
 	}
-	switch t.Type {
-	default:
-		return t.Raw < token.Raw
-	case String:
+	if t.Type == String {
 		if caseSensitive {
 			return t.Str < token.Str
 		}
 		return stringLessInsensitive(t.Str, token.Str)
-	case Multi:
+	}
+	if t.Type == Number {
+		return t.Num < token.Num
+	}
+	if t.Type == Multi {
 		for i := 0; i < len(t.Multi) && i < len(token.Multi); i++ {
 			if t.Multi[i].Less(token.Multi[i], caseSensitive) {
 				return true
@@ -715,9 +717,8 @@ func (t Result) Less(token Result, caseSensitive bool) bool {
 			}
 		}
 		return len(t.Multi) < len(token.Multi)
-	case Number:
-		return t.Num < token.Num
 	}
+	return t.Raw < token.Raw
 }
 
 func stringLessInsensitive(a, b string) bool {