Use STLExtras where applicable
MODIFY
src/assembler/gnudirectives.cpp
src/assembler/gnudirectives.cpp
@@ -169,9 +169,7 @@ Directive zeroDirective() {
int64_t value;
getImmediateErroring(arg.line.tokens.at(0), value, arg.line.sourceLine);
QByteArray bytes;
- for (int i = 0; i < value; i++) {
- bytes.append(static_cast<char>(0x0));
- }
+ bytes.fill(0x0, value);
return {bytes};
};
return Directive(".zero", zeroFunctor);

MODIFY
src/registermodel.cpp
src/registermodel.cpp
#include <QHeaderView>
+#include "STLExtras.h"
#include "fonts.h"
#include "processorhandler.h"
@@ -15,9 +16,8 @@ RegisterModel::RegisterModel(RegisterFileType rft, QObject* parent) : QAbstractT
std::vector<VInt> RegisterModel::gatherRegisterValues() {
std::vector<VInt> vals;
- for (int i = 0; i < rowCount(); i++) {
+ for (int i = 0; i < rowCount(); ++i)
vals.push_back(ProcessorHandler::getRegisterValue(m_rft, i));
- }
return vals;
}
@@ -35,10 +35,10 @@ void RegisterModel::processorWasClocked() {
endResetModel();
const auto newRegValues = gatherRegisterValues();
if (m_regValues.size() != 0) {
- for (unsigned i = 0; i < newRegValues.size(); i++) {
- if (m_regValues[i] != newRegValues[i]) {
- m_mostRecentlyModifiedReg = i;
- emit registerChanged(i);
+ for (auto newRegVal : llvm::enumerate(newRegValues)) {
+ if (m_regValues[newRegVal.index()] != newRegVal.value()) {
+ m_mostRecentlyModifiedReg = newRegVal.index();
+ emit registerChanged(newRegVal.index());
break;
}
}

MODIFY
src/syscall/systemio.h
src/syscall/systemio.h
#include <sys/stat.h>
#include <stdexcept>
+#include "STLExtras.h"
#include "statusmanager.h"
namespace Ripes {
@@ -110,7 +111,7 @@ private:
// Reset all file information. Closes any open files and resets the arrays
static void resetFiles() {
- for (int i = 0; i < SYSCALL_MAXFILES; i++) {
+ for (int i = 0; i < SYSCALL_MAXFILES; ++i) {
close(i);
}
setupStdio();
@@ -177,12 +178,8 @@ private:
// Determine whether a given filename is already in use.
static bool filenameInUse(const QString& requestedFilename) {
- for (int i = 0; i < SYSCALL_MAXFILES; i++) {
- if (!fileNames[i].isEmpty() && fileNames[i] == requestedFilename) {
- return true;
- }
- }
- return false;
+ return llvm::any_of(fileNames,
+ [&](auto fn) { return !fn.second.isEmpty() && fn.second == requestedFilename; });
}
// Determine whether a given fd is already in use with the given flag.

Use STLExtras where applicable