cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32011] - [PATCH] buildList in AbstractDatabaseAction generates incorrect parameter list
Date Wed, 17 Nov 2004 14:13:17 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=32011>.
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=32011





------- Additional Comments From wchao@yahoo.com  2004-11-17 15:13 -------
I would create a boolean named prependComma. Initially prependComma depends on
whether begin > 0. Thereafter, prependComma is always true. That is no less
efficient within the loop and communicates the intent much more clearly than
some weird begin integer variable that keeps getting incremented within the
loop. See the following diff. It's a few more lines of code, but it increases
clarity, which I think is important in a large code base because complexity and
confusion add up here and there.

--- AbstractDatabaseAction.java~        Fri Jul  9 04:03:11 2004
+++ AbstractDatabaseAction.java Wed Nov 17 09:09:09 2004
@@ -723,11 +723,13 @@
     protected StringBuffer buildList(Configuration[] values, int begin) throws
ConfigurationException {
         StringBuffer buffer = new StringBuffer();
         int length = values.length;
+                               boolean prependComma = (begin > 0);
         for (int i = 0; i < length; i++) {
-            if (begin > 0) {
+            if (prependComma) {
                 buffer.append(", ");
             }
             buffer.append(values[i].getAttribute("dbcol"));
+                                               prependComma = true;
         }
         return buffer;
     }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message