XenoAmess edited a comment on pull request #27:
URL: https://github.com/apache/commons-beanutils/pull/27#issuecomment-636465013


   > If your app does not need synchronization, you can use the map in "fast" 
mode.
   
   @garydgregory 
   Thanks. usually we need synchronization, and even when I need weak reference 
I will never clone the whole map everytime putting a single key-value pair.
   I really doubt why we shall do it this way.
   ```
   (from WeakFastHashMap.java)
   @Override
       public V put(final K key, final V value) {
           if (fast) {
               synchronized (this) {
                   final Map<K, V> temp = cloneMap(map);
                   final V result = temp.put(key, value);
                   map = temp;
                   return result;
               }
           }
           synchronized (map) {
               return map.put(key, value);
           }
       }
   ```
   Any suggestions?
   Should we make a counter and add 1 every time we put a key-value pair, and 
clone it only when the counter exceed some point?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to