You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Dave Brosius (JIRA)" <xa...@xml.apache.org> on 2005/10/21 06:52:44 UTC

[jira] Created: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

[PATCH] cleaup some String usage sillyness
------------------------------------------

         Key: XALANJ-2217
         URL: http://issues.apache.org/jira/browse/XALANJ-2217
     Project: XalanJ2
        Type: Improvement
    Versions: Latest Development Code    
 Environment: n/a
    Reporter: Dave Brosius
    Priority: Trivial


This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.

-- 
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


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


Re: [jira] Resolved: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by Libor Valenta <li...@atypon.com>.
Hi guys,

the most readeble conversion char to String is Character.toString(char 
c) which is by Sun implemented as String.valueOf(c) so the patch is 
correct on that.

-- LV

Brian Minchau (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/XALANJ-2217?page=all ]
>     
>Brian Minchau resolved XALANJ-2217:
>-----------------------------------
>
>    Fix Version: Latest Development Code
>     Resolution: Fixed
>
>The patch supplied by Dave was reviewed/approved/applied by myself. It was applied with one exception. The change to ElemNumber was not applied. 
>
>I was not convinced that these were the same for a given char, ch:
>  
>
>>   String.valueOf(ch) 
>>  (new Character(ch)).toString(); 
>>    
>>
>
>Perhaps they result in the same String, or perhaps in the given context for the limited range of ch values that would be used they are the same, but I was not convinced. Also, I checked if this code path was ever taken for the "build smoketest" or "build alltest.conf" test buckets. The code path was not exercised, so it also lowered my confidence.
>
>  
>
>>[PATCH] cleaup some String usage sillyness
>>------------------------------------------
>>
>>         Key: XALANJ-2217
>>         URL: http://issues.apache.org/jira/browse/XALANJ-2217
>>     Project: XalanJ2
>>        Type: Improvement
>>    Versions: Latest Development Code
>> Environment: n/a
>>    Reporter: Dave Brosius
>>    Assignee: Brian Minchau
>>    Priority: Trivial
>>     Fix For: Latest Development Code
>> Attachments: silly_string_stuff.diff
>>
>>This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.
>>    
>>
>
>  
>


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


[jira] Resolved: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2217?page=all ]
     
Brian Minchau resolved XALANJ-2217:
-----------------------------------

    Fix Version: Latest Development Code
     Resolution: Fixed

The patch supplied by Dave was reviewed/approved/applied by myself. It was applied with one exception. The change to ElemNumber was not applied. 

I was not convinced that these were the same for a given char, ch:
>    String.valueOf(ch) 
>   (new Character(ch)).toString(); 

Perhaps they result in the same String, or perhaps in the given context for the limited range of ch values that would be used they are the same, but I was not convinced. Also, I checked if this code path was ever taken for the "build smoketest" or "build alltest.conf" test buckets. The code path was not exercised, so it also lowered my confidence.

> [PATCH] cleaup some String usage sillyness
> ------------------------------------------
>
>          Key: XALANJ-2217
>          URL: http://issues.apache.org/jira/browse/XALANJ-2217
>      Project: XalanJ2
>         Type: Improvement
>     Versions: Latest Development Code
>  Environment: n/a
>     Reporter: Dave Brosius
>     Assignee: Brian Minchau
>     Priority: Trivial
>      Fix For: Latest Development Code
>  Attachments: silly_string_stuff.diff
>
> This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.

-- 
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


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


Re: [jira] Commented: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by db...@qis.net.
I'm sure Character.toString and String.valueOf(char) are the same, however, if
you are worried, it's fine by me if you don't make that one change.


Quoting "Brian Minchau (JIRA)" <xa...@xml.apache.org>:

>     [
>
http://issues.apache.org/jira/browse/XALANJ-2217?page=comments#action_12332734
> ] 
> 
> Brian Minchau commented on XALANJ-2217:
> ---------------------------------------
> 
> Dave, I'm ready to commit the patch, but have one issue I'm not sure of.
> 
> -----------------------------------------------
> Most are trivial .toString() methods called on a String, object, so the call
> is useless, and could even
> create an additional String for no reason at all.  I'm fine with these.
> ------------------------------------------------
> OpMap has this change 
>     new Integer(stepType).toString()     
>                 ------------->    String.valueOf(stepType) 
> where stepType is an int.  I looked up the Javadoc on String.valueOf(int) at
>    
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#valueOf(int)
> and it said this:
>     "The representation is exactly the one returned by the Integer.toString
> method of one argument. "
> so I'm OK with that one.
> 
> ------------------------------------------------
> 
> The only change in the whole patch that has me concerned is the one in
> ElemNumber
> 
>     (new Character(table.getChar((int)val - 1))).toString();
>                    ----------->    String.valueOf(table.getChar((int)val -
> 1));  
> table.getChar(int index) returns a char.    I'm not sure that for a given
> char, ch, that
>     String.valueOf(ch)
> is the same as 
>     (new Character(ch)).toString();
> 
> The javadoc at:
>    
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#valueOf(char)
> says this:
>     >> Returns the string representation of the char argument.
> 
> The javadoc for Charcter.toString() at:
>    
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html#toString()
> says this:
>     >> Returns a String object representing this Character's value. 
>     >>The result is a string of length 1 whose sole component is the
> primitive
>     >> char value represented by this Character object. 
> 
> So are these always the same? I'm worried about some subtle differences
> between char and Character.
> Perhaps the current locale can leak in somehow?  I don't know for sure, just
> have my worries about this one.
> 
> These are always the same, then I'm ready to commit the patch to the code
> base.
> - Brian
> 
> 
> 
> 
> 
> 
> > [PATCH] cleaup some String usage sillyness
> > ------------------------------------------
> >
> >          Key: XALANJ-2217
> >          URL: http://issues.apache.org/jira/browse/XALANJ-2217
> >      Project: XalanJ2
> >         Type: Improvement
> >     Versions: Latest Development Code
> >  Environment: n/a
> >     Reporter: Dave Brosius
> >     Priority: Trivial
> >  Attachments: silly_string_stuff.diff
> >
> > This patch cleans up some String class sillyness like creating an object
> just to convert to string, or calling toString on a String, etc.
> 
> -- 
> 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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xalan-dev-help@xml.apache.org
> 




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


[jira] Commented: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2217?page=comments#action_12332734 ] 

Brian Minchau commented on XALANJ-2217:
---------------------------------------

Dave, I'm ready to commit the patch, but have one issue I'm not sure of.

-----------------------------------------------
Most are trivial .toString() methods called on a String, object, so the call is useless, and could even
create an additional String for no reason at all.  I'm fine with these.
------------------------------------------------
OpMap has this change 
    new Integer(stepType).toString()     
                ------------->    String.valueOf(stepType) 
where stepType is an int.  I looked up the Javadoc on String.valueOf(int) at
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#valueOf(int)
and it said this:
    "The representation is exactly the one returned by the Integer.toString method of one argument. "
so I'm OK with that one.

------------------------------------------------

The only change in the whole patch that has me concerned is the one in ElemNumber

    (new Character(table.getChar((int)val - 1))).toString();
                   ----------->    String.valueOf(table.getChar((int)val - 1));  
table.getChar(int index) returns a char.    I'm not sure that for a given char, ch, that
    String.valueOf(ch)
is the same as 
    (new Character(ch)).toString();

The javadoc at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#valueOf(char)
says this:
    >> Returns the string representation of the char argument.

The javadoc for Charcter.toString() at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html#toString()
says this:
    >> Returns a String object representing this Character's value. 
    >>The result is a string of length 1 whose sole component is the primitive
    >> char value represented by this Character object. 

So are these always the same? I'm worried about some subtle differences between char and Character.
Perhaps the current locale can leak in somehow?  I don't know for sure, just have my worries about this one.

These are always the same, then I'm ready to commit the patch to the code base.
- Brian






> [PATCH] cleaup some String usage sillyness
> ------------------------------------------
>
>          Key: XALANJ-2217
>          URL: http://issues.apache.org/jira/browse/XALANJ-2217
>      Project: XalanJ2
>         Type: Improvement
>     Versions: Latest Development Code
>  Environment: n/a
>     Reporter: Dave Brosius
>     Priority: Trivial
>  Attachments: silly_string_stuff.diff
>
> This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.

-- 
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


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


[jira] Closed: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by "Dave Brosius (JIRA)" <xa...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XALANJ-2217?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dave Brosius closed XALANJ-2217.
--------------------------------


Patch applied correctly (with noted missing String.valueOf(ch) change)

> [PATCH] cleaup some String usage sillyness
> ------------------------------------------
>
>                 Key: XALANJ-2217
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2217
>             Project: XalanJ2
>          Issue Type: Improvement
>    Affects Versions: 2.7
>         Environment: n/a
>            Reporter: Dave Brosius
>            Assignee: Brian Minchau
>            Priority: Trivial
>             Fix For: 2.7.1
>
>         Attachments: silly_string_stuff.diff, silly_string_stuff_2.diff
>
>
> This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Assigned: (XALANJ-2217) [PATCH] cleaup some String usage sillyness

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2217?page=all ]

Brian Minchau reassigned XALANJ-2217:
-------------------------------------

    Assign To: Brian Minchau

> [PATCH] cleaup some String usage sillyness
> ------------------------------------------
>
>          Key: XALANJ-2217
>          URL: http://issues.apache.org/jira/browse/XALANJ-2217
>      Project: XalanJ2
>         Type: Improvement
>     Versions: Latest Development Code
>  Environment: n/a
>     Reporter: Dave Brosius
>     Assignee: Brian Minchau
>     Priority: Trivial
>  Attachments: silly_string_stuff.diff
>
> This patch cleans up some String class sillyness like creating an object just to convert to string, or calling toString on a String, etc.

-- 
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


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