You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Funk (JIRA)" <ji...@apache.org> on 2007/05/04 15:29:15 UTC
[jira] Created: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
--------------------------------------------------------------------------------------------
Key: WICKET-532
URL: https://issues.apache.org/jira/browse/WICKET-532
Project: Wicket
Issue Type: Improvement
Environment: svn info
Pfad: .
URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
Basis des Projektarchivs: https://svn.apache.org/repos/asf
UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
Revision: 535220
Reporter: Martin Funk
Priority: Minor
Attachments: patch.txt
This is not a bug, it's rather a 'finger exercise'.
Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493854 ]
Igor Vaynberg commented on WICKET-532:
--------------------------------------
i changed line 445 to final List list = new ArrayList(size); not sure why you suggested size-1
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Assigned To: Jonathan Locke
> Priority: Minor
> Fix For: 1.3
>
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Eelco Hillenius (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eelco Hillenius reassigned WICKET-532:
--------------------------------------
Assignee: Jonathan Locke
Jonathan coded this, so I'm assigning to him to see whether he has a strong opinion on this.
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Assigned To: Jonathan Locke
> Priority: Minor
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493706 ]
Igor Vaynberg commented on WICKET-532:
--------------------------------------
the reason it was hard to read is because it is an optimization for size. im not sure we want to remove it. we have code like that all over the place where we keep lists - except for component.behaviors, there its a list.
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Priority: Minor
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Jonathan Locke (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jonathan Locke resolved WICKET-532.
-----------------------------------
Resolution: Won't Fix
Fix Version/s: 1.3
We appreciate the effort, but the code is as it was intended to be: more space efficient than readable.
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Assigned To: Jonathan Locke
> Priority: Minor
> Fix For: 1.3
>
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Martin Funk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Funk updated WICKET-532:
-------------------------------
Attachment: patch.txt
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Priority: Minor
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Jonathan Locke (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493819 ]
Jonathan Locke commented on WICKET-532:
---------------------------------------
this implementation is hidden from users and provides worthwhile space optimization across potentially enormous numbers of components. nobody who is not a core committer has to read this and we should NOT change it to make it less space efficient!
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Assigned To: Jonathan Locke
> Priority: Minor
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-532) CodeSmell
jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
Posted by "Martin Funk (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493800 ]
Martin Funk commented on WICKET-532:
------------------------------------
This made me play around with Runtime.getRuntime().totalMemory(); Runtime.getRuntime().freeMemory(); and System.gc(); Trying to get a hint on memory footprint. Wouldn't even dare to call em hard facts.
On my system (64bit) new ArrayList(x) semms to be constantly 40 bytes bigger than new Object[x]. Also new ArrayList() seems to default to new ArrayList(10)
So if one reasons that a FormComponent rarely ever has more than one validator attached, chances are that the original aproach relatively has a significantly more efficient memory usage.
It's still ugly to read:-)
So if bytes are to tight mention I'd only have this patch to add (though the method doesn't seem to be used):
Index: wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
===================================================================
--- wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java (revision 535378)
+++ wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java (working copy)
@@ -442,7 +442,7 @@
}
else
{
- final List list = new ArrayList();
+ final List list = new ArrayList(size - 1);
for (int i = 0; i < size; i++)
{
list.add(validators_get(i));
> CodeSmell jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
> --------------------------------------------------------------------------------------------
>
> Key: WICKET-532
> URL: https://issues.apache.org/jira/browse/WICKET-532
> Project: Wicket
> Issue Type: Improvement
> Environment: svn info
> Pfad: .
> URL: https://svn.apache.org/repos/asf/incubator/wicket/trunk
> Basis des Projektarchivs: https://svn.apache.org/repos/asf
> UUID des Projektarchivs: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 535220
> Reporter: Martin Funk
> Priority: Minor
> Attachments: patch.txt
>
>
> This is not a bug, it's rather a 'finger exercise'.
> Whilst codereading I came across code I didn't understand, so I rewrote it. I ended up with something that I find easier to read.
> Maybe someone has some leasure time to read it and give me some feedback on it.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.