You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/10/31 22:14:58 UTC
svn commit: r590835 -
/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
Author: nbubna
Date: Wed Oct 31 14:14:57 2007
New Revision: 590835
URL: http://svn.apache.org/viewvc?rev=590835&view=rev
Log:
refactor addAllParameters() to be a bit more efficient
Modified:
velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
Modified: velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java?rev=590835&r1=590834&r2=590835&view=diff
==============================================================================
--- velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java (original)
+++ velocity/tools/trunk/src/java/org/apache/velocity/tools/view/tools/LinkTool.java Wed Oct 31 14:14:57 2007
@@ -905,29 +905,31 @@
*
* @return A LinkTool object with all of the current request's parameters
* added to it.
- *
* @see #addIgnore(String)
*/
public LinkTool addAllParameters()
{
- // Since we're adding all these parameters at once, there's no
- // reason to make a copy of each LinkTool along the way, as might
- // be done if we wrapped a call to addQueryData in a loop over
- // all request parameters.
- //
- // Instead, we copy the current parameters, filter out those we
- // want to ignore, and then use the copyWith(Map) method to
- // copy all the parameters into this LinkTool.
- HashMap params = new HashMap(request.getParameterMap());
-
- if (parametersToIgnore != null && parametersToIgnore.size() > 0)
+ if (this.parametersToIgnore != null)
{
+ // Since we're adding all these parameters at once, there's no
+ // reason to make a copy of each LinkTool along the way, as might
+ // be done if we wrapped a call to addQueryData in a loop over
+ // all request parameters.
+ //
+ // Instead, we copy the current parameters, filter out those we
+ // want to ignore, and then use the copyWith(Map) method to
+ // copy all the parameters into this LinkTool.
+ Map params = new HashMap(request.getParameterMap());
for (Iterator i = parametersToIgnore.iterator(); i.hasNext();)
{
params.remove(i.next());
}
+ return copyWith(params);
+ }
+ else
+ {
+ return copyWith(request.getParameterMap());
}
- return copyWith(params);
}