Browse Source

use copy constructor Simplified copying of Hashtables in propertyhelper.java

PR: 30163
Obtained from: Jesse Glick


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276852 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
f16558e639
1 changed files with 2 additions and 21 deletions
  1. +2
    -21
      src/main/org/apache/tools/ant/PropertyHelper.java

+ 2
- 21
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -477,19 +477,9 @@ public class PropertyHelper {
* (including user properties).
*/
public Hashtable getProperties() {
Hashtable propertiesCopy = new Hashtable();

Enumeration e = properties.keys();
while (e.hasMoreElements()) {
Object name = e.nextElement();
Object value = properties.get(name);
propertiesCopy.put(name, value);
}

return new Hashtable(properties);
// There is a better way to save the context. This shouldn't
// delegate to next, it's for backward compatibility only.

return propertiesCopy;
}

/**
@@ -497,16 +487,7 @@ public class PropertyHelper {
* @return a hashtable containing just the user properties
*/
public Hashtable getUserProperties() {
Hashtable propertiesCopy = new Hashtable();

Enumeration e = userProperties.keys();
while (e.hasMoreElements()) {
Object name = e.nextElement();
Object value = properties.get(name);
propertiesCopy.put(name, value);
}

return propertiesCopy;
return new Hashtable(userProperties);
}

/**


Loading…
Cancel
Save