String parsing on arduino side slow

Hi all-

I've converted an Uno-based light strip controller I made to now run on the Yun and add Wifi control.

Everything works, but when I pass 3 arguments (RGB) via REST, it takes quite a bit longer to actually execute the code, and so I assume I am using a very slow parsing method.

For example, if I just hit the API /arduino/off/1, this code executes near-instantaneously:

 String query = client.readString();
 byte begIndex = 0;
 byte pause = query.indexOf('/');
 String command = query.substring(begIndex,pause); 
//some if checks on command I am leaving out for clarity, you'll see it below
  else if (command == "off") {
        BlinkM_fadeToRGB(addr, 0,0,0);
 }

However, this code, which parses the command "color" for 3 values (RGB) takes about 5 seconds, which is a noticeable lag for a light controller:

String query = client.readString();
    byte begIndex = 0;
    byte pause = query.indexOf('/');
    String command = query.substring(begIndex,pause);
      if (command == "color") {
        byte currIndex = pause + 1;
        pause = query.indexOf("/",currIndex);
        red = query.substring(currIndex,pause).toInt();
         currIndex = pause + 1;
        pause = query.indexOf("/",currIndex);
        green = query.substring(currIndex,pause).toInt();
                 currIndex = pause + 1;
        pause = query.indexOf("/",currIndex);
        blue = query.substring(currIndex,pause).toInt();
        BlinkM_fadeToRGB(addr, red, green, blue);
      }
      else if (command == "off") {
        BlinkM_fadeToRGB(addr, 0,0,0);
      }

Executing "off" with that color code still works instantly, I assume because it isn't doing any further string parsing. Once it knows OFF it's just executing the BlinkM code and it's working great. Other commands I have added in this same loop work instantly as long as they are only containing one argument to parse. So it's not the conditionals or the BlinkM code, it's my cruddy string parsing.

I don't want to break RGB into separate REST calls on the Linino side, because the BlinkM I am using to power and control the strip (I grumble at Yun not having 12v) can do a really nice looking and extremely fast fade from one color to another using its built-in code. So I need to feed it the destination values for RGB all at the same time.

It has been a long while since I did string wrangling via C and so I'm hoping there's a more Arduino-friendly and faster way to do this kind of parsing that will make the performance of this one command closer to the others.

Thanks in advance!

Try using

client.parseInt();

This sped it up considerably! It's running as fast as the other API calls now, thanks so much!