From 7f7adca0ac624280241d1b681da86eccdd238073 Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Sat, 1 Jun 2019 10:48:31 -0500 Subject: [PATCH] #776 .dat files don't call restore_stls in checkpoint restore --- include/trick/MemoryManager.hh | 2 +- .../MemoryManager/MemoryManager_restore.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/trick/MemoryManager.hh b/include/trick/MemoryManager.hh index 36776831..e5aaae84 100644 --- a/include/trick/MemoryManager.hh +++ b/include/trick/MemoryManager.hh @@ -370,7 +370,7 @@ namespace Trick { Restore a checkpoint from the given stream. @param in_s - input stream. */ - int read_checkpoint( std::istream* in_s); + int read_checkpoint( std::istream* in_s, bool do_restore_stls=true); /** Read a checkpoint from the file of the given name. diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_restore.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_restore.cpp index 3f0083c7..588b565c 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_restore.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_restore.cpp @@ -7,7 +7,7 @@ #include "trick/MemoryManager.hh" #include "trick/ClassicCheckPointAgent.hh" -int Trick::MemoryManager::read_checkpoint( std::istream *is) { +int Trick::MemoryManager::read_checkpoint( std::istream *is, bool do_restore_stls /* default is true */) { ALLOC_INFO_MAP::iterator pos; ALLOC_INFO* alloc_info; @@ -22,7 +22,7 @@ int Trick::MemoryManager::read_checkpoint( std::istream *is) { } // Search for stls and restore them - for ( pos=alloc_info_map.begin() ; pos!=alloc_info_map.end() ; pos++ ) { + for ( pos=alloc_info_map.begin() ; do_restore_stls && pos!=alloc_info_map.end() ; pos++ ) { restore_stls(pos->second) ; } @@ -60,12 +60,17 @@ int Trick::MemoryManager::read_checkpoint(const char* filename ) { // Create a stream from the named file. std::ifstream infile(filename , std::ios::in); - if (infile.is_open()) { - return ( read_checkpoint( &infile )); + + // If the file extention is .dat, we will tell read_checkpoint not to + // restore stls. It is not necessary and time consuming. + bool do_restore_stls = + (std::string(filename).find(".dat") != std::string::npos); + + return ( read_checkpoint( &infile, do_restore_stls )) ; } else { std::stringstream message; - message << "Couldn't open \"" << filename << "\"."; + message << "Couldn't open \"" << filename << "\"." ; emitError(message.str()); } return 1;