summaryrefslogtreecommitdiff
path: root/ace/Hashable.inl
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Hashable.inl')
-rw-r--r--ace/Hashable.inl27
1 files changed, 27 insertions, 0 deletions
diff --git a/ace/Hashable.inl b/ace/Hashable.inl
new file mode 100644
index 00000000000..554c55a5d0a
--- /dev/null
+++ b/ace/Hashable.inl
@@ -0,0 +1,27 @@
+/* -*- C++ -*- */
+
+ACE_INLINE
+ACE_Hashable::ACE_Hashable (void)
+ : hash_value_ (0)
+{
+}
+
+ACE_INLINE
+ACE_Hashable::~ACE_Hashable (void)
+{
+}
+
+ACE_INLINE u_long
+ACE_Hashable::hash (void) const
+{
+ // In doing the check below, we take chance of paying a performance
+ // price when the hash value is zero. But, that will (hopefully)
+ // happen far less often than a non-zero value, so this caching
+ // strategy should pay off, esp. if hash computation is expensive
+ // relative to the simple comparison.
+
+ if (this->hash_value_ == 0)
+ ((ACE_Hashable *) this)->hash_value_ = this->hash_i ();
+
+ return this->hash_value_;
+}