Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2017-09-27 03:35:59 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2017-09-27 03:35:59 +0300
commit537542f682a595c2cc87855b2430246ab0b57bd8 (patch)
treeee9eb03bd3599ebbb2a7aefa7183514972ca8255 /server/TracyCharUtil.hpp
parentd65d957272f5e6cb427f39fb93fedcc671347930 (diff)
Add character utilities.
Diffstat (limited to 'server/TracyCharUtil.hpp')
-rwxr-xr-xserver/TracyCharUtil.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/server/TracyCharUtil.hpp b/server/TracyCharUtil.hpp
new file mode 100755
index 00000000..408e59dd
--- /dev/null
+++ b/server/TracyCharUtil.hpp
@@ -0,0 +1,53 @@
+#ifndef __TRACY__CHARUTIL_HPP__
+#define __TRACY__CHARUTIL_HPP__
+
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+namespace tracy
+{
+namespace charutil
+{
+
+static inline uint32_t hash( const char* str )
+{
+ uint32_t hash = 5381;
+ int c;
+
+ while( c = *str++ )
+ {
+ hash = ( ( hash << 5 ) + hash ) ^ c;
+ }
+
+ return hash;
+}
+
+struct Hasher
+{
+ size_t operator()( const char* key ) const
+ {
+ return hash( key );
+ }
+};
+
+struct Comparator
+{
+ bool operator()( const char* lhs, const char* rhs ) const
+ {
+ return strcmp( lhs, rhs ) == 0;
+ }
+};
+
+struct LessComparator
+{
+ bool operator()( const char* lhs, const char* rhs ) const
+ {
+ return strcmp( lhs, rhs ) < 0;
+ }
+};
+
+}
+}
+
+#endif