Skip to content

Commit 396ff28

Browse files
authored
LongVectors: fix unnecessary copy of the input data (microsoft#7746)
Previously getInputValueSetByKey returned a copy of the input data, which was then copied again into the actual input set, with the size adjusted. This change just uses a reference to the raw data set, and inlines the operation to get that reference.
1 parent 7f80fbc commit 396ff28

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

tools/clang/unittests/HLSLExec/LongVectors.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -654,15 +654,12 @@ DATA_TYPE_NAME(double, L"float64");
654654

655655
#undef DATA_TYPE_NAME
656656

657-
template <typename DATA_TYPE>
658-
std::vector<DATA_TYPE> buildTestInput(const wchar_t *InputValueSetName,
659-
size_t SizeToTest) {
660-
// TODO: remove the need to build up a RawValueSet, only to use that to build
661-
// ValueSet.
662-
std::vector<DATA_TYPE> RawValueSet =
663-
getInputValueSetByKey<DATA_TYPE>(InputValueSetName);
664-
665-
std::vector<DATA_TYPE> ValueSet;
657+
template <typename T>
658+
std::vector<T> buildTestInput(const wchar_t *InputValueSetName,
659+
size_t SizeToTest) {
660+
const std::vector<T> &RawValueSet = TestData<T>::Data.at(InputValueSetName);
661+
662+
std::vector<T> ValueSet;
666663
ValueSet.reserve(SizeToTest);
667664
for (size_t I = 0; I < SizeToTest; ++I)
668665
ValueSet.push_back(RawValueSet[I % RawValueSet.size()]);

tools/clang/unittests/HLSLExec/LongVectors.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,6 @@ getTernaryMathOpType(const std::wstring &OpTypeString) {
277277
OpTypeString);
278278
}
279279

280-
template <typename T>
281-
std::vector<T> getInputValueSetByKey(const std::wstring &Key,
282-
bool LogKey = true) {
283-
if (LogKey)
284-
WEX::Logging::Log::Comment(
285-
WEX::Common::String().Format(L"Using Value Set Key: %s", Key.c_str()));
286-
return std::vector<T>(TestData<T>::Data.at(Key));
287-
}
288-
289280
class OpTest {
290281
public:
291282
BEGIN_TEST_CLASS(OpTest)

0 commit comments

Comments
 (0)