From 6cb72314f1d60e0836e7fe7aedad2872051f148f Mon Sep 17 00:00:00 2001 From: "pabs@pablotron.org" Date: Thu, 18 Dec 2014 16:09:13 -0500 Subject: handle empty argument list more efficiently --- java/pablotron/luigi/Parser.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/pablotron/luigi/Parser.java b/java/pablotron/luigi/Parser.java index 6bf2638..207df86 100644 --- a/java/pablotron/luigi/Parser.java +++ b/java/pablotron/luigi/Parser.java @@ -87,6 +87,8 @@ public final class Parser { return r.toArray(new Action[r.size()]); } + private static final String[] NO_ARGS = {}; + public static FilterReference[] parse_filters( String filters_str ) throws LuigiError { @@ -104,8 +106,14 @@ public final class Parser { if (!m.find()) throw new LuigiError("invalid filter: " + f); + // get arguments string + String args = m.group(2).trim(); + // append new filter reference to result - r.add(new FilterReference(m.group(1), RE_DELIM_ARGS.split(m.group(2).trim()))); + r.add(new FilterReference( + m.group(1), + (args.length() > 0) ? RE_DELIM_ARGS.split(args) : NO_ARGS + )); } // return result -- cgit v1.2.3