Skip to content

Commit

Permalink
Replace boost::container::flat_map with robin_map
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmkuruc committed Apr 3, 2023
1 parent 9642956 commit 90e1c82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions pxr/usd/usd/crateFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2624,7 +2624,7 @@ CrateFile::_AddDeferredSpecs()
{
// A map from sample time to VtValues within TimeSamples instances in
// _deferredSpecs.
boost::container::flat_map<double, vector<VtValue *>> allValuesAtAllTimes;
pxr_tsl::robin_map<double, vector<VtValue *>> allValuesAtAllTimes;

// Search for the TimeSamples, add to the allValuesAtAllTimes.
for (auto &spec: _deferredSpecs) {
Expand All @@ -2638,12 +2638,22 @@ CrateFile::_AddDeferredSpecs()
}
}

// Create a sorted view of the underlying map keys.
std::vector<double> orderedTimes(allValuesAtAllTimes.size());
std::transform(std::cbegin(allValuesAtAllTimes),
std::cend(allValuesAtAllTimes),
std::begin(orderedTimes),
[](const auto& element) { return element.first; });
std::sort(orderedTimes.begin(), orderedTimes.end());

// Now walk through allValuesAtAllTimes in order and pack all the values,
// swapping them out with the resulting reps. This ensures that when we
// pack the specs, which will re-pack the values, they'll be noops since
// they are just holding value reps that point into the file.
for (auto const &p: allValuesAtAllTimes) {
for (VtValue *val: p.second)
for (auto const &t: orderedTimes) {
auto it = allValuesAtAllTimes.find(t);
TF_DEV_AXIOM(it != allValuesAtAllTimes.end());
for (VtValue *val: it->second)
*val = _PackValue(*val);
}

Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/usd/crateFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "pxr/base/arch/fileSystem.h"
#include "pxr/base/tf/hash.h"
#include "pxr/base/tf/pxrTslRobinMap/robin_map.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/vt/array.h"
#include "pxr/base/vt/value.h"
Expand All @@ -43,7 +44,6 @@
#include "pxr/usd/sdf/path.h"
#include "pxr/usd/sdf/types.h"

#include <boost/container/flat_map.hpp>
#include <boost/intrusive_ptr.hpp>

#include <tbb/concurrent_unordered_set.h>
Expand Down Expand Up @@ -1046,7 +1046,7 @@ class CrateFile
mutable tbb::spin_rw_mutex _sharedTimesMutex;

// functions to write VtValues to file by type.
boost::container::flat_map<
pxr_tsl::robin_map<
std::type_index, std::function<ValueRep (VtValue const &)>>
_packValueFunctions;

Expand Down

0 comments on commit 90e1c82

Please sign in to comment.