gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. 0dd6b94867ec42c4b8a5


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 0dd6b94867ec42c4b8a5897cd12f4711d0dcc42f
Date: Fri, 10 Sep 2010 02:13:27 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  0dd6b94867ec42c4b8a5897cd12f4711d0dcc42f (commit)
      from  5d7d58ece991883b8dc906ca1e8dfe5c718d8738 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=0dd6b94867ec42c4b8a5897cd12f4711d0dcc42f


commit 0dd6b94867ec42c4b8a5897cd12f4711d0dcc42f
Author: Sandro Santilli <address@hidden>
Date:   Fri Sep 10 04:13:20 2010 +0200

    Add string_table stat machinery (dirty, but damn useful. disabled by 
default)

diff --git a/libbase/string_table.cpp b/libbase/string_table.cpp
index a58bd6d..2014fb9 100644
--- a/libbase/string_table.cpp
+++ b/libbase/string_table.cpp
@@ -20,8 +20,47 @@
 #include "string_table.h"
 #include <boost/algorithm/string/case_conv.hpp>
 
+//#define DEBUG_STRING_TABLE 1
+
+#ifdef DEBUG_STRING_TABLE
+# include <iostream>
+# include <iomanip>
+#endif
+
 namespace gnash {
 
+#ifdef DEBUG_STRING_TABLE
+    namespace {
+    class KeyCaseLookup {
+        typedef std::map<string_table::key, unsigned long int> Stat;
+        Stat stat;
+        const string_table* _st;
+    public:
+        KeyCaseLookup(const string_table* st) : _st(st) {}
+
+        void check(string_table::key k) {
+            ++stat[k];
+        }
+        ~KeyCaseLookup(){ 
+            typedef std::map<unsigned long int, string_table::key> Sorted;
+            Sorted sorted;
+            for (Stat::iterator i=stat.begin(), e=stat.end(); i!=e; ++i)
+                sorted[i->second] = i->first;
+            for (Sorted::reverse_iterator i=sorted.rbegin(), e=sorted.rend();
+                    i!=e; ++i)
+                std::cerr
+                          << std::setw(10)
+                          << i->first
+                          << ":"
+                          << _st->value(i->second) << "("
+                          << i->second << ")"
+                          << std::endl;
+        }
+    };
+    } // namespace anonymous
+#endif // DEBUG_STRING_TABLE
+
+
 const std::string string_table::_empty;
 
 string_table::key
@@ -79,6 +118,10 @@ string_table::insert_group(const svt* l, std::size_t size)
             _caseTable[s.id] = already_locked_insert(t);
         }
     }
+#ifdef DEBUG_STRING_TABLE
+    std::cerr << "string_table group insert end -- size is " << _table.size() 
<< " _caseTable size is " << _caseTable.size() << std::endl; 
+#endif
+
 
 }
 
@@ -87,6 +130,12 @@ string_table::already_locked_insert(const std::string& 
to_insert)
 {
        const key ret = _table.insert(svt(to_insert, ++_highestKey)).first->id;
 
+#ifdef DEBUG_STRING_TABLE
+    int tscp = 20; // table size checkpoint
+    size_t ts = _table.size();
+    if ( ! (ts % tscp) ) { std::cerr << "string_table size grew to " << ts << 
std::endl; }
+#endif
+
     const std::string lower = boost::to_lower_copy(to_insert);
 
     // Insert the caseless equivalent if it's not there. We're locked for
@@ -100,6 +149,11 @@ string_table::already_locked_insert(const std::string& 
to_insert)
         const key nocase = (it == _table.end()) ? 
             _table.insert(svt(lower, ++_highestKey)).first->id : it->id;
 
+#ifdef DEBUG_STRING_TABLE
+        ++ts;
+        if ( ! (ts % tscp) ) { std::cerr << "string_table size grew to " << ts 
<< std::endl; }
+#endif // DEBUG_STRING_TABLE
+
         _caseTable[ret] = nocase;
 
     }
@@ -110,6 +164,14 @@ string_table::already_locked_insert(const std::string& 
to_insert)
 string_table::key
 string_table::noCase(key a) const
 {
+#ifdef DEBUG_STRING_TABLE
+    static KeyCaseLookup kcl(this);
+    kcl.check(a);
+#endif // DEBUG_STRING_TABLE
+
+    // The empty string (key 0) is equal to its lowercase version..
+    if ( ! a ) return a;
+
     std::map<key, key>::const_iterator i = _caseTable.find(a);
     return i == _caseTable.end() ? a : i->second;
 }

-----------------------------------------------------------------------

Summary of changes:
 libbase/string_table.cpp |   62 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]