comment = "; // ";
}
+ if (! tstruct->has_fingerprint()) {
+ tstruct->generate_fingerprint(); // lazy fingerprint generation
+ }
if (tstruct->has_fingerprint()) {
out <<
indent() << stat << "const char* " << nspace
return;
}
ttype = get_true_type(ttype);
- assert(ttype->has_fingerprint());
string key = ttype->get_ascii_fingerprint() + (is_definition ? "-defn" : "-decl");
+ assert(ttype->has_fingerprint()); // test AFTER get due to lazy fingerprint generation
+
// Note that we have generated this fingerprint. If we already did, bail out.
if (!reflected_fingerprints_.insert(key).second) {
return;
try {
pverbose("Program: %s\n", program->get_path().c_str());
- // Compute fingerprints.
- generate_all_fingerprints(program);
+ // Compute fingerprints. - not anymore, we do it on the fly now
+ //generate_all_fingerprints(program);
if (dump_docs) {
dump_docstrings(program);
#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() {
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;
return false;
}
- const uint8_t* get_binary_fingerprint() const {
+ const uint8_t* get_binary_fingerprint() {
+ if(! has_fingerprint()) // lazy fingerprint generation, right now only used with the c++ generator
+ generate_fingerprint();
return fingerprint_;
}
- std::string get_ascii_fingerprint() const {
+ std::string get_ascii_fingerprint() {
std::string rv;
const uint8_t* fp = get_binary_fingerprint();
for (int i = 0; i < fingerprint_len; i++) {