Return early from parseOptions
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 19 Mar 2016 16:12:10 +0000 (17:12 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 19 Mar 2016 16:12:10 +0000 (17:12 +0100)
helpers/pygments.go

index b6a325000cc9f9acd72d4bf5d9d32211248eba5a..fe14ad49fc256bd4246b9b880895456184866d4b 100644 (file)
@@ -158,15 +158,18 @@ func init() {
 
 func parseOptions(options map[string]string, in string) error {
        in = strings.Trim(in, " ")
-       if in != "" {
-               for _, v := range strings.Split(in, ",") {
-                       keyVal := strings.Split(v, "=")
-                       key := strings.ToLower(strings.Trim(keyVal[0], " "))
-                       if len(keyVal) != 2 || !pygmentsKeywords[key] {
-                               return fmt.Errorf("invalid Pygments option: %s", key)
-                       }
-                       options[key] = keyVal[1]
+
+       if in == "" {
+               return nil
+       }
+
+       for _, v := range strings.Split(in, ",") {
+               keyVal := strings.Split(v, "=")
+               key := strings.ToLower(strings.Trim(keyVal[0], " "))
+               if len(keyVal) != 2 || !pygmentsKeywords[key] {
+                       return fmt.Errorf("invalid Pygments option: %s", key)
                }
+               options[key] = keyVal[1]
        }
 
        return nil