Additional: wiquery does a lot with StringBuffer, but concats also with '+'. It
is more efficient to use append (because concate with '+' ends up compiled to
StringBuilder).
Example in org.odlabs.wiquery.core.javascript.helper.DateHelper#getJSDate
StringBuffer dateJavascript = new StringBuffer();
dateJavascript.append("new Date(");
dateJavascript.append(calendar.get(Calendar.YEAR) + ",");
dateJavascript.append(calendar.get(Calendar.MONTH) + ",");
dateJavascript.append(calendar.get(Calendar.DAY_OF_MONTH) + ",");
dateJavascript.append(calendar.get(Calendar.HOUR_OF_DAY) + ",");
dateJavascript.append(calendar.get(Calendar.MINUTE) + ",");
dateJavascript.append(calendar.get(Calendar.SECOND) + ",");
dateJavascript.append(calendar.get(Calendar.MILLISECOND));
dateJavascript.append(")");
..this is like you would write:
StringBuffer dateJavascript = new StringBuffer();
dateJavascript.append("new Date(");
dateJavascript.append(new StringBuilder(calendar.get(Calendar.YEAR)).append(",").toString());
dateJavascript.append(new StringBuilder(calendar.get(Calendar.MONTH)).append(",").toString());
dateJavascript.append(new StringBuilder(calendar.get(Calendar.DAY_OF_MONTH)).append(",").toString());
dateJavascript.append(new StringBuilder(calendar.get(Calendar.HOUR_OF_DAY)).append(",").toString());
dateJavascript.append(new StringBuilder(calendar.get(Calendar.MINUTE)).append(",").toString());
dateJavascript.append(new StringBuilder(calendar.get(Calendar.SECOND)).append(",").toString());
dateJavascript.append(calendar.get(Calendar.MILLISECOND));
dateJavascript.append(")");
...so better use also append:
StringBuffer dateJavascript = new StringBuffer();
dateJavascript.append("new Date(");
dateJavascript.append(calendar.get(Calendar.YEAR)).append(",");
dateJavascript.append(calendar.get(Calendar.MONTH)).append(",");
dateJavascript.append(calendar.get(Calendar.DAY_OF_MONTH)).append(",");
dateJavascript.append(calendar.get(Calendar.HOUR_OF_DAY)).append(",");
dateJavascript.append(calendar.get(Calendar.MINUTE)).append(",");
dateJavascript.append(calendar.get(Calendar.SECOND)).append(",");
dateJavascript.append(calendar.get(Calendar.MILLISECOND));
dateJavascript.append(")");
... review patch2.patch
Original issue reported on code.google.com by hielke.hoeve on 11 May 2011 at 7:12
Original issue reported on code.google.com by
hielke.hoeve
on 11 May 2011 at 7:12Attachments: