activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQCPP-527
Date Wed, 11 Dec 2013 19:25:18 GMT
Updated Branches:
  refs/heads/trunk 9d2f8788f -> 6a4d00aa6


https://issues.apache.org/jira/browse/AMQCPP-527

work around bad Microsoft STL Map impls.  

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/6a4d00aa
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/6a4d00aa
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/6a4d00aa

Branch: refs/heads/trunk
Commit: 6a4d00aa68d374bed3dd16fb68cbef60fe90dd16
Parents: 9d2f878
Author: Timothy Bish <tabish121@gmai.com>
Authored: Wed Dec 11 14:25:15 2013 -0500
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Wed Dec 11 14:25:15 2013 -0500

----------------------------------------------------------------------
 .../decaf/util/concurrent/ConcurrentStlMap.h    | 36 ++++++++++++--------
 1 file changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/6a4d00aa/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
index 087c069..05fdd91 100644
--- a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
+++ b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
@@ -774,8 +774,10 @@ namespace concurrent{
             typename std::map<K, V, COMPARATOR>::const_iterator iter;
 
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                return iter != valueMap.end();
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    return iter != valueMap.end();
+                }
             }
 
             return false;
@@ -829,9 +831,11 @@ namespace concurrent{
         virtual V& get(const K& key) {
             typename std::map<K,V,COMPARATOR>::iterator iter;
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                if (iter != valueMap.end()) {
-                    return iter->second;
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    if (iter != valueMap.end()) {
+                        return iter->second;
+                    }
                 }
             }
 
@@ -845,9 +849,11 @@ namespace concurrent{
         virtual const V& get(const K& key) const {
             typename std::map<K,V,COMPARATOR>::const_iterator iter;
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                if (iter != valueMap.end()) {
-                    return iter->second;
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    if (iter != valueMap.end()) {
+                        return iter->second;
+                    }
                 }
             }
 
@@ -916,13 +922,15 @@ namespace concurrent{
         virtual V remove(const K& key) {
             V result = V();
             synchronized(&mutex) {
-                typename std::map<K, V, COMPARATOR>::iterator iter = valueMap.find(key);
-                if (iter == valueMap.end()) {
-                    return result;
+                if (!valueMap.empty()) {
+                    typename std::map<K, V, COMPARATOR>::iterator iter = valueMap.find(key);
+                    if (iter == valueMap.end()) {
+                        return result;
+                    }
+                    result = iter->second;
+                    valueMap.erase(iter);
+                    modCount++;
                 }
-                result = iter->second;
-                valueMap.erase(iter);
-                modCount++;
             }
 
             return result;


Mime
View raw message