THRIFT-2200: nested structs cause generate_fingerprint() to slow down at excessive CPU load
Patch: Jens Geyer
diff --git a/compiler/cpp/src/parse/parse.cc b/compiler/cpp/src/parse/parse.cc
index a655652..4b42f66 100644
--- a/compiler/cpp/src/parse/parse.cc
+++ b/compiler/cpp/src/parse/parse.cc
@@ -2,13 +2,17 @@
#include "t_typedef.h"
#include "md5.h"
+#include "main.h"
void t_type::generate_fingerprint() {
- std::string material = get_fingerprint_material();
- md5_state_t ctx;
- md5_init(&ctx);
- md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size());
- md5_finish(&ctx, (md5_byte_t*)fingerprint_);
+ if (! has_fingerprint()) {
+ pdebug("generating fingerprint for %s", get_name().c_str());
+ std::string material = get_fingerprint_material();
+ md5_state_t ctx;
+ md5_init(&ctx);
+ md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size());
+ md5_finish(&ctx, (md5_byte_t*)fingerprint_);
+ }
}
t_type* t_type::get_true_type() {