Index: src/java/org/apache/turbine/om/peer/BasePeer.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/om/peer/BasePeer.java,v
retrieving revision 1.25
diff -r1.25 BasePeer.java
[ snip ]
1062a1083,1100
>
> Statement stmt = null;
> boolean doTransaction = false;
> if ( db.objectDataNeedsTrans() )
> {
> for (int i = 0; i<tables.size(); i++)
> {
> doTransaction = doTransaction ||
> containsObjectColumn(dbMap, tables.get(i));
> }
> }
>
> if ( doTransaction )
> {
> stmt = dbCon.createStatement();
> stmt.executeUpdate("BEGIN TRANSACTION");
> stmt.close();
> }
[ snip ]
Hi Nissim! I think that this snippet would be better written as:
for (int i = 0; i < tables.size(); i++)
{
if (containsObjectColumn(dbMap, tables.get(i)))
{
// Perform the transaction.
Statement stmt = dbCon.createStatement();
stmt.executeUpdate("BEGIN TRANSACTION");
stmt.close();
// No point in continuing the search...bail out of the loop.
break;
}
}
I haven't looked at how moving those local variables affects the
surrounding code, but I'm sure you get the idea (once it's obvious that
the transaction should be done, stop checking). :)
--
Daniel Rall <[EMAIL PROTECTED]>
http://collab.net/ | open source | do the right thing
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]