[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/con...
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/con... |
Date: |
Sat, 23 Jun 2007 12:34:32 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Bastiaan Jacques <bjacques> 07/06/23 12:34:32
Modified files:
. : ChangeLog
libbase : Makefile.am container.cpp container.h
server : fontlib.cpp impl.cpp
Log message:
* libbase/container.h: Remove home-made container classes in
favour of standard containers.
* server/{fontlib, impl}.cpp: Switch hash to std::map.
* libbase/container.cpp: Remove unused container tests.
* libbase/Makefile.am: Disable building of unused container.cpp.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3602&r2=1.3603
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/container.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/container.h?cvsroot=gnash&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fontlib.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.109&r2=1.110
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3602
retrieving revision 1.3603
diff -u -b -r1.3602 -r1.3603
--- ChangeLog 22 Jun 2007 22:07:07 -0000 1.3602
+++ ChangeLog 23 Jun 2007 12:34:31 -0000 1.3603
@@ -1,3 +1,11 @@
+2007-06-23 Bastiaan Jacques <address@hidden>
+
+ * libbase/container.h: Remove home-made container classes in
+ favour of standard containers.
+ * server/{fontlib, impl}.cpp: Switch hash to std::map.
+ * libbase/container.cpp: Remove unused container tests.
+ * libbase/Makefile.am: Disable building of unused container.cpp.
+
2007-06-22 Bastiaan Jacques <address@hidden>
* macros/kde.m4: look for libkdeui, not kdeui. Also first check
Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- libbase/Makefile.am 15 Jun 2007 15:00:26 -0000 1.74
+++ libbase/Makefile.am 23 Jun 2007 12:34:32 -0000 1.75
@@ -79,7 +79,6 @@
libgnashbase_la_SOURCES = \
config.cpp \
- container.cpp \
$(DMALLOC_FILE) \
extension.cpp \
image.cpp \
Index: libbase/container.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- libbase/container.cpp 15 Apr 2007 10:52:09 -0000 1.14
+++ libbase/container.cpp 23 Jun 2007 12:34:32 -0000 1.15
@@ -9,161 +9,3 @@
#include "config.h"
#endif
-#include <cmath>
-#include <cstdio>
-#include <cstdarg>
-
-#include "container.h"
-#include "utf8.h"
-#include "tu_random.h"
-
-
-#ifdef CONTAINER_UNIT_TEST
-
-
-// Compile this test case with something like:
-//
-// gcc container.cpp utf8.cpp tu_random.cpp -g -I.. -DCONTAINER_UNIT_TEST
-lstdc++ -o container_test
-//
-// or
-//
-// cl container.cpp utf8.cpp tu_random.cpp -Zi -Od -DCONTAINER_UNIT_TEST -I..
-
-
-void test_hash()
-{
- // Collect a bunch of random key/value pairs.
- std::vector<uint32_t> data;
- for (int i = 0; i < 1000; i++)
- {
- data.push_back(tu_random::next_random());
- }
-
- // Push into hash.
- hash<uint32_t, uint32_t> h;
- {for (int i = 0; i < data.size() / 2; i++)
- {
- h.add(data[i*2], data[i*2 + 1]);
-
- // Verify the contents of the hash so far.
- for (int j = 0; j < i; j++)
- {
- uint32_t key = data[j*2];
- uint32_t val;
- bool got = h.get(key, &val);
- assert(got);
- assert(val == data[j*2 + 1]);
- }
- }}
-
- // Manually copy stuff over to h2, using iterator interface.
- hash<uint32_t, uint32_t> h2;
- {for (hash<uint32_t, uint32_t>::iterator it = h.begin(); it != h.end();
++it)
- {
- //printf("first = 0x%X, second = 0x%X\n", it->first,
it->second);//xxxxx
- assert(h.get(it->first, NULL) == true);
-
- h2.add(it->first, it->second);
-
- uint32_t val;
- bool got = h2.get(it->first, &val);
- assert(got);
- assert(val == it->second);
- }}
-
- // Verify the contents of h2.
- {for (int i = 0; i < data.size() / 2; i++)
- {
- uint32_t key = data[i*2];
- uint32_t val;
- bool got = h.get(key, &val);
- assert(got);
- assert(val == data[i*2 + 1]);
- }}
-
- h.clear();
- assert(h.size() == 0);
-
- // Verify that h really is missing the stuff it had before, and h2
really has it.
- {for (hash<uint32_t, uint32_t>::iterator it = h2.begin(); it !=
h2.end(); ++it)
- {
- assert(h.get(it->first, NULL) == false);
- assert(h2.get(it->first, NULL) == true);
- assert(h.find(it->first) == h.end());
- assert(h2.find(it->first) != h2.end());
- }}
-}
-
-
-//#include <ext/hash_map>
-//#include <hash_map>
-//#include <map>
-
-void test_hash_speed()
-// Test function for hash performance of adding keys and doing lookup.
-{
-
-// Hash type, for doing comparative tests.
-//
-// tu_hash tests faster than the map and hash_map included with GCC
-// 3.3 as well as map and hash_map from MSVC7. In some cases, several
-// times faster. GCC's hash_map is the closest to tu_hash, but is
-// still 33% slower in my tests.
-
-// // tu's hash
-#define HASH hash<uint32_t, uint32_t >
-#define HASH_ADD(h, k, v) h.add(k, v)
-
-// STL's hash
-//#define HASH __gnu_cxx::hash_map<uint32_t, uint32_t>
-//#define HASH std::hash_map<uint32_t, uint32_t>
-//#define HASH_ADD(h, k, v) h[k] = v
-
-// STL's map
-//#define HASH std::map<uint32_t, uint32_t>
-//#define HASH_ADD(h, k, v) h[k] = v
-
-// const int SIZE = 10000000;
- const int SIZE = 1000000;
-
- // Make an array of random numbers.
- std::vector<uint32_t> numbers;
- numbers.resize(SIZE);
-
- for (int i = 0, n = numbers.size(); i < n; i++)
- {
- numbers[i] = tu_random::next_random();
- }
-
- // Uniquify the array.
- HASH new_index;
- int next_new_index = 0;
- {for (int i = 0, n = numbers.size(); i < n; i++)
- {
- HASH::iterator it = new_index.find(numbers[i]);
- if (it == new_index.end())
- {
- // First time this number has been seen.
- HASH_ADD(new_index, numbers[i], next_new_index);
- next_new_index++;
- }
- else
- {
- // This number already appears in the list.
-// printf("duplicate entry %x, prev new index %d, current
array index %d\n",
-// numbers[i],
-// it->second,
-// i);
- }
- }}
-
- printf("next_new_index = %d\n", next_new_index);
-}
-
-#endif // CONTAINER_UNIT_TEST
-
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
Index: libbase/container.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- libbase/container.h 28 May 2007 15:41:01 -0000 1.57
+++ libbase/container.h 23 Jun 2007 12:34:32 -0000 1.58
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: container.h,v 1.57 2007/05/28 15:41:01 ann Exp $ */
+/* $Id: container.h,v 1.58 2007/06/23 12:34:32 bjacques Exp $ */
#ifndef __CONTAINER_H__
#define __CONTAINER_H__
@@ -26,14 +26,6 @@
#include "tu_config.h"
-#ifdef WIN32_HASH_MAP
-# include <hash_map>
-#else
-# ifdef GNU_HASH_MAP
-# include <ext/hash_map>
-# endif
-#endif
-
#ifdef HAVE_STRINGCASECMP
# define STRCASECMP strcasecmp
#else
@@ -73,646 +65,12 @@
//#include <new> // for placement new
#include <vector>
-
-template<class T>
-class fixed_size_hash
-// Computes a hash of an object's representation.
-{
-public:
- size_t operator()(const T& data) const
- {
- const unsigned char* p = (const unsigned char*) &data;
- int size = sizeof(T);
-
- return sdbm_hash(p, size);
- }
-};
-
-
-template<class T>
-class identity_hash
-// Hash is just the input value; can use this for integer-indexed hash tables.
-{
-public:
- size_t operator()(const T& data) const
- {
- return (size_t) data;
- }
-};
-
-
-//
-// Thin wrappers around STL
-//
-
-
-//// @@@ crap compatibility crap
-//#define StlAlloc(size) malloc(size)
-//#define StlFree(ptr, size) free(ptr)
-
-// hash from gameSWF. There are compiler problems with stdext:hash in Visual C
-// Markus: As well as with other compilers...
-namespace gnash{
-
-#ifdef WIN32_HASH_MAP
-
-template<class T, class U, class hash_functor = fixed_size_hash<T> >
-class DSOEXPORT hash {
-// Hash table, linear probing, internal chaining. One
-// interesting/nice thing about this implementation is that the table
-// itself is a flat chunk of memory containing no pointers, only
-// relative indices. If the key and value types of the hash contain
-// no pointers, then the hash can be serialized using raw IO. Could
-// come in handy.
-//
-// Never shrinks, unless you explicitly clear() it. Expands on
-// demand, though. For best results, if you know roughly how big your
-// table will be, default it to that size when you create it.
-public:
- hash() : m_table(NULL) { }
- hash(int size_hint) : m_table(NULL) { set_capacity(size_hint); }
- ~hash() { clear(); }
-
- // @@ need a "remove()"
-// char& operator[](int index)
-// {
-// }
-
- U& operator[](const T& key)
- {
- int index = find_index(key);
- if (index >= 0)
- {
- return E(index).second;
- }
- add(key, (U) 0);
- index = find_index(key);
- if (index >= 0)
- {
- return E(index).second;
- }
- assert(0);
- return E(index).second; /* Doesn't look nice but removes
- warning on non-void function not
- returning. */
- }
-
- void set(const T& key, const U& value)
- // Set a new or existing value under the key, to the value.
- {
- int index = find_index(key);
- if (index >= 0)
- {
- E(index).second = value;
- return;
- }
-
- // Entry under key doesn't exist.
- add(key, value);
- }
-
- int erase(const T& key)
- {
- int i = find_index(key);
- if (i >= 0)
- {
- entry* e = &E(i);
- if (e->is_empty() == false)
- {
- e->clear();
- }
- return 1;
- }
- return 0;
- }
-
- void add(const T& key, const U& value)
- // Add a new value to the hash table, under the specified key.
- {
- assert(find_index(key) == -1);
-// if (find_index(key) != -1)
-// {
-// return;
-// }
-
- check_expand();
- assert(m_table);
- m_table->m_entry_count++;
-
- unsigned int hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
-
- entry* natural_entry = &(E(index));
-
- if (natural_entry->is_empty())
- {
- // Put the new entry in.
- new (natural_entry) entry(key, value, -1, hash_value);
- }
- else
- {
- // Find a blank spot.
- int blank_index = index;
- for (;;)
- {
- blank_index = (blank_index + 1) &
m_table->m_size_mask;
- if (E(blank_index).is_empty()) break; //
found it
- }
- entry* blank_entry = &E(blank_index);
-
- if (int(natural_entry->m_hash_value &
m_table->m_size_mask) == index)
- {
- // Collision. Link into this chain.
-
- // Move existing list head.
- new (blank_entry) entry(*natural_entry);
// placement new, copy ctor
-
- // Put the new info in the natural entry.
- natural_entry->first = key;
- natural_entry->second = value;
- natural_entry->m_next_in_chain = blank_index;
- natural_entry->m_hash_value = hash_value;
- }
- else
- {
- // Existing entry does not naturally
- // belong in this slot. Existing
- // entry must be moved.
-
- // Find natural location of collided element
(i.e. root of chain)
- int collided_index =
natural_entry->m_hash_value & m_table->m_size_mask;
- for (;;)
- {
- entry* e = &E(collided_index);
- if (e->m_next_in_chain == index)
- {
- // Here's where we need to
splice.
- new (blank_entry)
entry(*natural_entry);
- e->m_next_in_chain =
blank_index;
- break;
- }
- collided_index = e->m_next_in_chain;
- assert(collided_index >= 0 &&
collided_index <= m_table->m_size_mask);
- }
-
- // Put the new data in the natural entry.
- natural_entry->first = key;
- natural_entry->second = value;
- natural_entry->m_hash_value = hash_value;
- natural_entry->m_next_in_chain = -1;
- }
- }
- }
-
- void resize(int n)
- {
- clear();
- }
-
- void clear()
- // Remove all entries from the hash table.
- {
- if (m_table)
- {
- // Delete the entries.
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
- {
- entry* e = &E(i);
- if (e->is_empty() == false)
- {
- e->clear();
- }
- }
- tu_free(m_table, sizeof(table) + sizeof(entry) *
(m_table->m_size_mask + 1));
- m_table = NULL;
- }
- }
-
- bool empty() const
- {
- return is_empty();
- }
-
- bool is_empty() const
- // Returns true if the hash is empty.
- {
- return m_table == NULL || m_table->m_entry_count == 0;
- }
-
-
- bool get(const T& key, U* value) const
- // Retrieve the value under the given key.
- //
- // If there's no value under the key, then return false and leave
- // *value alone.
- //
- // If there is a value, return true, and set *value to the entry's
- // value.
- //
- // If value == NULL, return true or false according to the
- // presence of the key, but don't touch *value.
- {
- int index = find_index(key);
- if (index >= 0)
- {
- if (value) {
- *value = E(index).second;
- }
- return true;
- }
- return false;
- }
-
- int size() const
- {
- return m_table == NULL ? 0 : m_table->m_entry_count;
- }
-
- void check_expand()
- // Resize the hash table to fit one more entry. Often this
- // doesn't involve any action.
- {
- if (m_table == NULL) {
- // Initial creation of table. Make a minimum-sized
table.
- set_raw_capacity(16);
- } else if (m_table->m_entry_count * 3 > (m_table->m_size_mask +
1) * 2) {
- // Table is more than 2/3rds full. Expand.
- set_raw_capacity(m_table->m_entry_count * 2);
- }
- }
-
-
- void resize(size_t n)
- // Hint the bucket count to >= n.
- {
- // Not really sure what this means in relation to
- // STLport's hash_map... they say they "increase the
- // bucket count to at least n" -- but does that mean
- // their real capacity after resize(n) is more like
- // n*2 (since they do linked-list chaining within
- // buckets?).
- set_capacity(n);
- }
-
- void set_capacity(int new_size)
- // Size the hash so that it can comfortably contain the given
- // number of elements. If the hash already contains more
- // elements than new_size, then this may be a no-op.
- {
- int new_raw_size = (new_size * 3) / 2;
- if (new_raw_size < size()) { return; }
-
- set_raw_capacity(new_raw_size);
- }
-
- // Behaves much like std::pair
- class entry
- {
- public:
- int m_next_in_chain; // internal chaining for
collisions
- size_t m_hash_value; // avoids recomputing.
Worthwhile?
- T first;
- U second;
-
- entry() : m_next_in_chain(-2) {}
- entry(const entry& e)
- : m_next_in_chain(e.m_next_in_chain),
m_hash_value(e.m_hash_value), first(e.first), second(e.second)
- {
- }
- entry(const T& key, const U& value, int next_in_chain, int
hash_value)
- : m_next_in_chain(next_in_chain),
m_hash_value(hash_value), first(key), second(value)
- {
- }
- bool is_empty() const { return m_next_in_chain == -2; }
- bool is_end_of_chain() const { return m_next_in_chain == -1;
}
-
- void clear()
- {
- first.~T(); // placement delete
- second.~U(); // placement delete
- m_next_in_chain = -2;
- }
- };
-
- // Iterator API, like STL.
-
- class const_iterator
- {
- public:
- T get_key() const { return m_hash->E(m_index).first; }
- U get_value() const { return m_hash->E(m_index).second; }
-
- const entry& operator*() const
- {
- assert(is_end() == false &&
(m_hash->E(m_index).is_empty() == false));
- return m_hash->E(m_index);
- }
- const entry* operator->() const { return &(operator*()); }
-
- void operator++()
- {
- assert(m_hash);
-
- // Find next non-empty entry.
- if (m_index <= m_hash->m_table->m_size_mask)
- {
- m_index++;
- while (m_index <= m_hash->m_table->m_size_mask
- && m_hash->E(m_index).is_empty())
- {
- m_index++;
- }
- }
- }
-
- bool operator==(const const_iterator& it) const
- {
- if (is_end() && it.is_end())
- {
- return true;
- }
- else
- {
- return
- m_hash == it.m_hash
- && m_index == it.m_index;
- }
- }
-
- bool operator!=(const const_iterator& it) const { return !
(*this == it); }
-
-
- bool is_end() const
- {
- return
- m_hash == NULL
- || m_hash->m_table == NULL
- || m_index > m_hash->m_table->m_size_mask;
- }
-
- protected:
- friend class hash<T,U,hash_functor>;
-
- const_iterator(const hash* h, int index)
- :
- m_hash(h),
- m_index(index)
- {
- }
-
- const hash* m_hash;
- int m_index;
- };
- friend class const_iterator;
-
- // non-const iterator; get most of it from const_iterator.
- class iterator : public const_iterator
- {
- public:
- // Allow non-const access to entries.
- entry& operator*() const
- {
- assert(is_end() == false);
- return const_cast<hash*>(m_hash)->E(m_index);
- }
- entry* operator->() const { return &(operator*()); }
-
- private:
- friend class hash<T,U,hash_functor>;
-
- iterator(hash* h, int i0)
- :
- const_iterator(h, i0)
- {
- }
- };
- friend class iterator;
-
-
- iterator begin()
- {
- if (m_table == 0) return iterator(NULL, 0);
-
- // Scan til we hit the first valid entry.
- int i0 = 0;
- while (i0 <= m_table->m_size_mask
- && E(i0).is_empty())
- {
- i0++;
- }
- return iterator(this, i0);
- }
- iterator end() { return iterator(NULL, 0); }
-
- const_iterator begin() const { return
const_cast<hash*>(this)->begin(); }
- const_iterator end() const { return const_cast<hash*>(this)->end(); }
-
- iterator find(const T& key)
- {
- int index = find_index(key);
- if (index >= 0)
- {
- return iterator(this, index);
- }
- return iterator(NULL, 0);
- }
-
- const_iterator find(const T& key) const { return
const_cast<hash*>(this)->find(key); }
-
-private:
- void operator=(const hash& h) { assert(0); } // @@ TODO
-
- int find_index(const T& key) const
- // Find the index of the matching entry. If no match, then return -1.
- {
- if (m_table == NULL) return -1;
-
- size_t hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
-
- const entry* e = &E(index);
- if (e->is_empty()) return -1;
- if (int(e->m_hash_value & m_table->m_size_mask) != index)
return -1; // occupied by a collider
-
- for (;;)
- {
- assert((e->m_hash_value & m_table->m_size_mask) ==
(hash_value & m_table->m_size_mask));
-
- if (e->m_hash_value == hash_value && e->first == key)
- {
- // Found it.
- return index;
- }
- assert(! (e->first == key)); // keys are equal, but
hash differs!
-
- // Keep looking through the chain.
- index = e->m_next_in_chain;
- if (index == -1) break; // end of chain
-
- assert(index >= 0 && index <= m_table->m_size_mask);
- e = &E(index);
-
- assert(e->is_empty() == false);
- }
- return -1;
- }
-
- // Helpers.
- entry& E(int index)
- {
- assert(m_table);
- assert(index >= 0 && index <= m_table->m_size_mask);
- return *(((entry*) (m_table + 1)) + index);
- }
- const entry& E(int index) const
- {
- assert(m_table);
- assert(index >= 0 && index <= m_table->m_size_mask);
- return *(((entry*) (m_table + 1)) + index);
- }
-
-
- void set_raw_capacity(int new_size)
- // Resize the hash table to the given size (Rehash the
- // contents of the current table). The arg is the number of
- // hash table entries, not the number of elements we should
- // actually contain (which will be less than this).
- {
- if (new_size <= 0) {
- // Special case.
- clear();
- return;
- }
-
- // Force new_size to be a power of two.
- int bits = fchop(log2((float)(new_size-1)) + 1);
- assert((1 << bits) >= new_size);
-
- new_size = 1 << bits;
-
- hash<T, U, hash_functor> new_hash;
- new_hash.m_table = (table*) tu_malloc(sizeof(table) +
sizeof(entry) * new_size);
- assert(new_hash.m_table); // @@ need to throw (or
something) on malloc failure!
-
- new_hash.m_table->m_entry_count = 0;
- new_hash.m_table->m_size_mask = new_size - 1;
- {for (int i = 0; i < new_size; i++)
- {
- new_hash.E(i).m_next_in_chain = -2; // mark empty
- }}
-
- // Copy stuff to new_hash
- if (m_table)
- {
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
- {
- entry* e = &E(i);
- if (e->is_empty() == false)
- {
- // Insert old entry into new hash.
- new_hash.add(e->first, e->second);
- e->clear(); // placement delete of
old element
- }
- }
-
- // Delete our old data buffer.
- tu_free(m_table, sizeof(table) + sizeof(entry) *
(m_table->m_size_mask + 1));
- }
-
- // Steal new_hash's data.
- m_table = new_hash.m_table;
- new_hash.m_table = NULL;
- }
-
- struct table
- {
- int m_entry_count;
- int m_size_mask;
- // entry array goes here!
- };
- table* m_table;
-}; // WIN32 hash end
-#else
-
-template<class T, class U, class hash_functor = fixed_size_hash<T> >
-class DSOEXPORT hash : public __gnu_cxx::hash_map<T, U, hash_functor >
-{
-public:
- typedef typename __gnu_cxx::hash_map<T, U,
hash_functor>::const_iterator const_iterator;
- typedef typename __gnu_cxx::hash_map<T, U, hash_functor>::iterator
iterator;
-
- // extra convenience interfaces
- void add(const T& key, const U& value)
- {
- assert(find(key) == this->end());
- (*this)[key] = value;
- }
-
- bool get(const T& key, U* value) const
- // Retrieve the value under the given key.
- //
- // If there's no value under the key, then return false and leave
- // *value alone.
- //
- // If there is a value, return true, and set *value to the entry's
- // value.
- //
- // If value == NULL, return true or false according to the
- // presence of the key, but don't touch *value.
- {
- const_iterator it = find(key);
- if (it != this->end())
- {
- if (value) *value = it->second;
- return true;
- }
- else
- {
- return false;
- }
- }
-};
-#endif //GNUC
-
-} // namespace gnash
-
-
-//
-// Homemade containers; almost strict subsets of STL.
-//
-
+namespace gnash {}
#if defined(_WIN32) || defined(WIN32)
#pragma warning(disable : 4345) // in MSVC 7.1, warning about placement
new POD default initializer
#endif // _WIN32
-template<class T>
-class string_hash_functor
-// Computes a hash of a string-like object (something that has
-// ::length() and ::[int]).
-{
-public:
- size_t operator()(const T& data) const
- {
- int size = data.length();
-
- return bernstein_hash((const char*) data, size);
- }
-};
-
-template<class T>
-class stringi_hash_functor
-// Computes a case-insensitive hash of a string-like object (something that has
-// ::length() and ::[int] and tolower(::[])).
-{
-public:
- size_t operator()(const T& data) const
- {
- int size = data.length();
-
- return bernstein_hash_case_insensitive((const char*) data,
size);
- }
-};
#endif // __CONTAINER_H__
Index: server/fontlib.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fontlib.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/fontlib.cpp 15 Jun 2007 15:00:29 -0000 1.29
+++ server/fontlib.cpp 23 Jun 2007 12:34:32 -0000 1.30
@@ -5,7 +5,7 @@
// A module to take care of all of gnash's loaded fonts.
-/* $Id: fontlib.cpp,v 1.29 2007/06/15 15:00:29 strk Exp $ */
+/* $Id: fontlib.cpp,v 1.30 2007/06/23 12:34:32 bjacques Exp $ */
#include "container.h"
#include "tu_file.h"
@@ -643,7 +643,7 @@
bool try_to_reuse_previous_image(
const rendered_glyph_info& rgi,
- const hash<unsigned int, const rendered_glyph_info*>&
image_hash)
+ const map<unsigned int, const rendered_glyph_info*>& image_hash)
// See if we've already packed an identical glyph image for
// another glyph. If so, then reuse it, and return true.
// If no reusable image, return false.
@@ -652,8 +652,16 @@
// fonts that use the same dummy glyph for many undefined
// characters.
{
+ const map<unsigned int, const
rendered_glyph_info*>::const_iterator image =
+ image_hash.find(rgi.m_image_hash);
+
+
const rendered_glyph_info* identical_image = NULL;
- if (image_hash.get(rgi.m_image_hash, &identical_image))
+ if (image != image_hash.end()) {
+ identical_image = (*image).second;
+ }
+
+ if (identical_image)
{
// Found a match. But is it *really* a match? Do a
// bitwise compare.
@@ -783,7 +791,7 @@
// Share identical texture data where possible, by
// doing glyph image comparisons.
- hash<unsigned int, const rendered_glyph_info*> image_hash;
+ map<unsigned int, const rendered_glyph_info*> image_hash;
// Pack the glyphs.
{for (int i = 0, n = glyph_info.size(); i < n; )
@@ -850,9 +858,11 @@
tg));
// Add this into the hash so it can
possibly be reused.
- if (image_hash.get(rgi.m_image_hash,
NULL) == false)
+ map<unsigned int, const
rendered_glyph_info*>::const_iterator image =
+
image_hash.find(rgi.m_image_hash);
+ if (image == image_hash.end())
{
-
image_hash.add(rgi.m_image_hash, &rgi);
+ image_hash[rgi.m_image_hash] =
&rgi;
}
packed[index] = true;
Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- server/impl.cpp 15 Jun 2007 15:00:29 -0000 1.109
+++ server/impl.cpp 23 Jun 2007 12:34:32 -0000 1.110
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: impl.cpp,v 1.109 2007/06/15 15:00:29 strk Exp $ */
+/* $Id: impl.cpp,v 1.110 2007/06/23 12:34:32 bjacques Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -646,7 +646,8 @@
static MovieLibrary s_movie_library;
-static hash< movie_definition*, boost::intrusive_ptr<sprite_instance> >
s_movie_library_inst;
+typedef std::map< movie_definition*, boost::intrusive_ptr<sprite_instance> >
library_container_t;
+static library_container_t s_movie_library_inst;
static std::vector<sprite_instance*> s_extern_sprites;
static std::string s_workdir;
@@ -742,11 +743,11 @@
{
// Is the movie instance already in the library?
{
- boost::intrusive_ptr<sprite_instance> m;
- s_movie_library_inst.get(md, &m);
- if (m != NULL)
+ library_container_t::const_iterator i = s_movie_library_inst.find(md);
+ if (i != s_movie_library_inst.end())
{
// Return cached movie instance.
+ boost::intrusive_ptr<sprite_instance> m((*i).second);
return m.get();
}
}
@@ -762,7 +763,7 @@
}
else
{
- s_movie_library_inst.add(md, mov);
+ s_movie_library_inst[md] = mov;
}
return mov;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/Makefile.am libbase/con...,
Bastiaan Jacques <=