]> git.tdb.fi Git - libs/gl.git/blobdiff - source/tag.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / tag.cpp
index c8041e0d0331c8c20fc7f78a657b39d651e5daab..af92bbb8b60780cb0827a63e8d0ea3c6795299d6 100644 (file)
@@ -1,21 +1,28 @@
 #include "tag.h"
 
+namespace {
+
+template<typename T>
+inline unsigned hash(T begin, T end)
+{
+       unsigned result = 0;
+       for(T i=begin; (i!=end && *i); ++i)
+               result = ((result>>29)|(result<<5))^static_cast<unsigned char>(*i);
+       return result;
+}
+
+}
+
 namespace Msp {
 namespace GL {
 
 Tag::Tag(const char *s):
-       id(0)
-{
-       for(const char *i=s; *i; ++i)
-               id=id*id+*i;
-}
+       id(s ? hash<const char *>(s, 0) : 0)
+{ }
 
 Tag::Tag(const std::string &s):
-       id(0)
-{
-       for(std::string::const_iterator i=s.begin(); i!=s.end(); ++i)
-               id=id*id+*i;
-}
+       id(hash(s.begin(), s.end()))
+{ }
 
 } // namespace GL
 } // namespace Msp