Skip to content

Commit

Permalink
Remove cacheing code. Make faster.
Browse files Browse the repository at this point in the history
Signed-off-by: Arjo Chakravarty <arjoc@google.com>
  • Loading branch information
arjo129 committed Oct 1, 2024
1 parent 0868abf commit 91228de
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
3 changes: 1 addition & 2 deletions include/sdf/SDFImpl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ namespace sdf
class SDFORMAT_VISIBLE SDF
{
public: SDF();
public: SDF(const SDF& other);//Copy constructor
/// \brief Destructor
public: virtual ~SDF();
public: ~SDF();
public: void PrintDescription();
public: void PrintDescription(sdf::Errors &_errors);
public: void PrintDoc();
Expand Down
13 changes: 3 additions & 10 deletions src/Root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,12 @@ Errors Root::LoadSdfString(const std::string &_sdf)
return this->LoadSdfString(_sdf, ParserConfig::GlobalConfig());
}

static SDFPtr cachedRoot;
static bool cacheActive = false;

/////////////////////////////////////////////////
Errors Root::LoadSdfString(const std::string &_sdf, const ParserConfig &_config)
{
Errors errors;
if (!cacheActive) {
cacheActive = true;
cachedRoot = std::make_shared<SDF>();
init(cachedRoot);
}
SDFPtr sdfParsed = std::make_shared<SDF>(*cachedRoot);
SDFPtr sdfParsed(new SDF());
init(sdfParsed);

// Read an SDF string, and store the result in sdfParsed.
if (!readString(_sdf, _config, sdfParsed, errors))
Expand Down Expand Up @@ -650,4 +643,4 @@ sdf::ElementPtr Root::ToElement(const OutputConfig &_config) const
}

return elem;
}
}
5 changes: 1 addition & 4 deletions src/SDF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ SDF::SDF()
: dataPtr(new SDFPrivate)
{
}
SDF::SDF(const SDF& other)
{
this->dataPtr = std::make_unique<SDFPrivate>(*other.dataPtr);
}

/////////////////////////////////////////////////
SDF::~SDF()
{
Expand Down
7 changes: 0 additions & 7 deletions src/SDFImplPrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ namespace sdf
{
}

public: SDFPrivate(const SDFPrivate& other)
{
this->path = other.path;
this->originalVersion = other.originalVersion;
this->root = other.root->Clone();
}

/// \brief Store the root element.
/// \sa ElementPtr Root()
/// \sa void Root(const ElementPtr _root)
Expand Down

0 comments on commit 91228de

Please sign in to comment.