]> git.tdb.fi Git - libs/gl.git/blobdiff - source/tag.cpp
Fix various issues with constant condition elimination
[libs/gl.git] / source / tag.cpp
index 3586507a5f8ba17c35a560b55fdbfb6990290672..c5824aec4e114d60b04c53acd00ae2b54072f7fe 100644 (file)
@@ -1,34 +1,16 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007, 2010  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
+#include <cstring>
+#include <msp/core/hash.h>
 #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(s ? hash<const char *>(s, 0) : 0)
+       id((s && *s) ? hash32(s, strlen(s)) : 0)
 { }
 
 Tag::Tag(const std::string &s):
-       id(hash(s.begin(), s.end()))
+       id(s.empty() ? 0 : hash32(s))
 { }
 
 } // namespace GL