ParamGenerator: Return the end iterator if any param is empty
Not doing so produces an infinite loop when iterating from begin to end. Bug: none Change-Id: I323587a19ba1618d7e9a326de2ee398ae5e0bb7b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51762 Auto-Submit: Austin Eng <enga@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
parent
aa11652207
commit
8bc3e68bd1
|
@ -46,7 +46,10 @@ class ParamGenerator {
|
|||
public:
|
||||
using value_type = ParamStruct;
|
||||
|
||||
ParamGenerator(std::vector<Params>... params) : mParams(params...) {
|
||||
ParamGenerator(std::vector<Params>... params) : mParams(params...), mIsEmpty(false) {
|
||||
for (bool isEmpty : {params.empty()...}) {
|
||||
mIsEmpty |= isEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
class Iterator : public std::iterator<std::forward_iterator_tag, ParamStruct, size_t> {
|
||||
|
@ -94,6 +97,9 @@ class ParamGenerator {
|
|||
};
|
||||
|
||||
Iterator begin() const {
|
||||
if (mIsEmpty) {
|
||||
return end();
|
||||
}
|
||||
return Iterator(mParams, {});
|
||||
}
|
||||
|
||||
|
@ -105,6 +111,7 @@ class ParamGenerator {
|
|||
|
||||
private:
|
||||
ParamTuple mParams;
|
||||
bool mIsEmpty;
|
||||
};
|
||||
|
||||
struct BackendTestConfig;
|
||||
|
|
Loading…
Reference in New Issue