commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31831] New: - Otiose Code in ParameterParser
Date Thu, 21 Oct 2004 17:37:27 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31831>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31831

Otiose Code in ParameterParser

           Summary: Otiose Code in ParameterParser
           Product: Commons
           Version: Nightly Builds
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: File Upload
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: michael@michaelmcgrady.com


The line "paramValue = null" is, I think, otiose in ParameterParser and
constitutes an operation that really does nothing except take up CPU space,
unless  the VM catches it, which I doubt, and ignores it.  Not sure if people
want to look at code this closely, but, if you do, then the code is:



  public Map parse(final char[] chars,
                   int offset,
                   int length,
                   char separator) {
    if (chars == null) {
      return new HashMap();
    }
    HashMap params = new HashMap();
    this.chars = chars;
    this.pos = offset;
    this.len = length;

    String paramName = null;
    String paramValue = null;
    while (hasChar()) {
      paramName = parseToken(new char[] { '=', separator });
      paramValue = null;
      if (hasChar() && (chars[pos] == '=')) {
        pos++; // skip '='
        paramValue = parseQuotedToken(new char[] { separator });
      }
      if (hasChar() && (chars[pos] == separator)) {
        pos++; // skip separator
      }
      if ((paramName != null) && (paramName.length() > 0)) {
        if (this.lowerCaseNames) {
          paramName = paramName.toLowerCase();
        }
        params.put(paramName, paramValue);
      }
    }
    return params;
  }

Michael McGrady

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message