Author: xor
Date: 2009-04-19 11:50:03 +0000 (Sun, 19 Apr 2009)
New Revision: 27039

Modified:
   trunk/freenet/src/freenet/support/SimpleFieldSet.java
Log:
SFS optimization: When putting a value with overwrite == true, do not get() the 
old one as we are overwriting it anyway.

Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java       2009-04-19 
10:50:50 UTC (rev 27038)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java       2009-04-19 
11:50:03 UTC (rev 27039)
@@ -295,15 +295,18 @@
                int idx;
                if(value == null) return true; // valid no-op
                if(value.indexOf('\n') != -1) throw new 
IllegalArgumentException("A simplefieldSet can't accept newlines !");
-               if((idx = key.indexOf(MULTI_LEVEL_CHAR)) == -1) {
-                       String x = values.get(key);
+               if((idx = key.indexOf(MULTI_LEVEL_CHAR)) == -1) {               
+                       if(!shortLived) key = key.intern();
                        
-                       if(!shortLived) key = key.intern();
-                       if(x == null || overwrite) {
+                       if(overwrite) {
                                values.put(key, value);
                        } else {
+                               if(values.get(key) == null) {
+                                       values.put(key, value);
+                               } else {
                                if(!allowMultiple) return false;
                                values.put(key, (values.get(key))+ 
MULTI_VALUE_CHAR +value);
+                               }
                        }
                } else {
                        String before = key.substring(0, idx);

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to