[ 
http://issues.apache.org/jira/browse/COCOON-1625?page=comments#action_12413702 
] 

aleksander.bandelj commented on COCOON-1625:
--------------------------------------------

In HttpRequest.java located

cocoon 2.0: 
core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
cocoon: 2.1: src/java/org/apache/cocoon/environment/http/HttpRequest.java

Proposed new getParameter method is:

    public String getParameter(String name) {
        String value = this.req.getParameter(name);
        if (this.form_encoding == null || this.container_encoding == null || 
value == null) {
            return value;
        }
        // form and container encoding are equal, skip expensive value decoding
        // XXX: maybe toUpperCase could be optimized away
        
if(this.container_encoding.toUpperCase().equals(this.form_encoding.toUpperCase()))
 {
            return value;
        }
        return decode(value);
    }


Current method calls decode() and copies parameter value string:

    public String getParameter(String name) {
        String value = this.req.getParameter(name);
        if (this.form_encoding == null || value == null) {
            return value;
        }
        return decode(value);
    }


    private String decode(String str) {
        if (str == null) return null;
        try {
            if (this.container_encoding == null)
                this.container_encoding = "ISO-8859-1";
            byte[] bytes = str.getBytes(this.container_encoding);
            return new String(bytes, form_encoding);
        } catch (java.io.UnsupportedEncodingException uee) {
            throw new RequestEncodingException("Unsupported Encoding 
Exception", uee);
        }
    }


> redundant copying between container and form encoding
> -----------------------------------------------------
>
>          Key: COCOON-1625
>          URL: http://issues.apache.org/jira/browse/COCOON-1625
>      Project: Cocoon
>         Type: Bug

>   Components: * Cocoon Core
>     Versions: 2.1.7
>  Environment: Operating System: other
> Platform: Other
>     Reporter: aleksander.bandelj
>     Assignee: Cocoon Developers Team

>
> Even if container and form encoding are the same, String is still copied. It
> would be nice to avoid this performance penalty by adding a check in
> HttpRequestClass.decode().
> Background: e use servlet filter which sets characterEncoding of
> ServletHttpRequest in front of cocoon, so form re-encoding by cocoon is not
> needed. Most natural way to skip it would be to set same default encodings in
> Cocoon servlet parameters.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to