Skip to content

Commit 6651099

Browse files
committed
workshop/Queue: pass Row to MakeJob()
1 parent 59de17a commit 6651099

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/workshop/Queue.cxx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ WorkshopQueue::GetNextScheduled(int *span_r)
9393
}
9494

9595
static WorkshopJob
96-
MakeJob(WorkshopQueue &queue,
97-
const Pg::Result &result, unsigned row)
96+
MakeJob(WorkshopQueue &queue, const Pg::Result::Row &row)
9897
{
9998
enum Columns {
10099
ID,
@@ -104,17 +103,15 @@ MakeJob(WorkshopQueue &queue,
104103
STDIN,
105104
};
106105

107-
assert(row < result.GetRowCount());
108-
109106
WorkshopJob job(queue);
110-
job.id = result.GetValue(row, ID);
111-
job.plan_name = result.GetValue(row, PLAN_NAME);
107+
job.id = row.GetValue(ID);
108+
job.plan_name = row.GetValue(PLAN_NAME);
112109

113-
job.args = Pg::DecodeArray(result.GetValue(row, ARGS));
114-
job.env = Pg::DecodeArray(result.GetValue(row, ENV));
110+
job.args = Pg::DecodeArray(row.GetValue(ARGS));
111+
job.env = Pg::DecodeArray(row.GetValue(ENV));
115112

116-
if (!result.IsValueNull(row, STDIN))
117-
job.stdin = Pg::DecodeHex(result.GetValueView(row, STDIN));
113+
if (!row.IsValueNull(STDIN))
114+
job.stdin = Pg::DecodeHex(row.GetValueView(STDIN));
118115

119116
if (job.id.empty())
120117
throw std::runtime_error("Job has no id");
@@ -177,9 +174,11 @@ WorkshopQueue::SetFilter(std::string &&_plans_include,
177174
void
178175
WorkshopQueue::RunResult(const Pg::Result &result)
179176
{
180-
for (unsigned row = 0, end = result.GetRowCount();
181-
row != end && IsEnabled() && !interrupt; ++row) {
182-
auto job = MakeJob(*this, result, row);
177+
for (const auto &row : result) {
178+
if (!IsEnabled() || interrupt)
179+
break;
180+
181+
auto job = MakeJob(*this, row);
183182
auto plan = handler.GetWorkshopPlan(job.plan_name.c_str());
184183

185184
if (plan &&

0 commit comments

Comments
 (0)