THRIFT-2200: nested structs cause generate_fingerprint() to slow down at excessive CPU load

Patch: Jens Geyer
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
index 1d03542..621f42e 100644
--- a/compiler/cpp/src/parse/t_struct.h
+++ b/compiler/cpp/src/parse/t_struct.h
@@ -147,10 +147,18 @@
 
   virtual std::string get_fingerprint_material() const {
     std::string rv = "{";
+    bool do_reserve = (members_in_id_order_.size() > 1);
+    size_t estimation = 0;
     members_type::const_iterator m_iter;
     for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
       rv += (*m_iter)->get_fingerprint_material();
       rv += ";";
+      
+      if( do_reserve) {
+        estimation = members_in_id_order_.size() * rv.size() + 16;
+        rv.reserve( estimation);
+        do_reserve = false;
+      }
     }
     rv += "}";
     return rv;