diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-08 08:01:35 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-08 12:01:14 +0200 |
commit | 7085fc97a7ce0cb58b7f93bcc0e915a46f5d4da1 (patch) | |
tree | 437add6305c53cda6e89e32ced4e3f80f81874af | |
parent | b60ec242aede00ef69510354a3a7b9724ab88195 (diff) |
shiboken6: Refactor OverloadData::numberOfRemovedArguments()
Split it into 2 functions for clarity.
Change-Id: I9c7b198030f6f5df5832a493b1fc2819568b91f6
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | sources/shiboken6/generator/shiboken/overloaddata.cpp | 24 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/overloaddata.h | 3 |
2 files changed, 16 insertions, 11 deletions
diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp index 5cf3b3f0c..ad358542b 100644 --- a/sources/shiboken6/generator/shiboken/overloaddata.cpp +++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp @@ -717,19 +717,23 @@ QList<int> OverloadData::invalidArgumentLengths() const return invalidArgLengths; } +int OverloadData::numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func) +{ + int removed = 0; + for (int i = 0, size = int(func->arguments().size()); i < size; ++i) { + if (func->argumentRemoved(i + 1)) + ++removed; + } + return removed; +} + int OverloadData::numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func, int finalArgPos) { + Q_ASSERT(finalArgPos >= 0); int removed = 0; - if (finalArgPos < 0) { - for (int i = 0; i < func->arguments().size(); i++) { - if (func->argumentRemoved(i + 1)) - removed++; - } - } else { - for (int i = 0; i < finalArgPos + removed; i++) { - if (func->argumentRemoved(i + 1)) - removed++; - } + for (int i = 0; i < finalArgPos + removed; ++i) { + if (func->argumentRemoved(i + 1)) + ++removed; } return removed; } diff --git a/sources/shiboken6/generator/shiboken/overloaddata.h b/sources/shiboken6/generator/shiboken/overloaddata.h index ae7d91715..d9c5bd24c 100644 --- a/sources/shiboken6/generator/shiboken/overloaddata.h +++ b/sources/shiboken6/generator/shiboken/overloaddata.h @@ -105,7 +105,8 @@ public: QList<int> invalidArgumentLengths() const; - static int numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func, int finalArgPos = -1); + static int numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func); + static int numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func, int finalArgPos); /// Returns true if all overloads have no more than one argument. static bool isSingleArgument(const AbstractMetaFunctionCList &overloads); |