]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/util/pointer.h
Increase performance of getLight() by at least 2x
[dragonfireclient.git] / src / util / pointer.h
index 02f11c2eaa28f9a7ad74cc3c2a970d69d1b5c8c7..7922a9b395734bc074e3a911e5f4cd06dde655fb 100644 (file)
@@ -1,6 +1,6 @@
 /*
-Minetest-c55
-Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+Minetest
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "../irrlichttypes.h"
 #include "../debug.h" // For assert()
+#include <cstring>
 
 template <typename T>
 class SharedPtr
@@ -196,6 +197,7 @@ class SharedBuffer
                else
                        data = NULL;
                refcount = new unsigned int;
+               memset(data,0,sizeof(T)*m_size);
                (*refcount) = 1;
        }
        SharedBuffer(const SharedBuffer &buffer)
@@ -221,7 +223,7 @@ class SharedBuffer
        /*
                Copies whole buffer
        */
-       SharedBuffer(T *t, unsigned int size)
+       SharedBuffer(const T *t, unsigned int size)
        {
                m_size = size;
                if(m_size != 0)
@@ -256,7 +258,7 @@ class SharedBuffer
        }
        T & operator[](unsigned int i) const
        {
-               //assert(i < m_size)
+               assert(i < m_size);
                return data[i];
        }
        T * operator*() const