File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -186,13 +186,12 @@ std::shared_ptr<Input> Block::inputAt(int index) const
186186/* ! Returns the index of the input with the given name. */
187187int Block::findInput (const std::string &inputName) const
188188{
189- int i = 0 ;
190- for (auto input : impl->inputs ) {
191- if (input->name () == inputName)
192- return i;
193- i++;
194- }
195- return -1 ;
189+ auto it = std::find_if (impl->inputs .begin (), impl->inputs .end (), [inputName](std::shared_ptr<Input> input) { return input->name () == inputName; });
190+
191+ if (it == impl->inputs .end ())
192+ return -1 ;
193+ else
194+ return it - impl->inputs .begin ();
196195}
197196
198197/* ! Returns the input with the given ID. */
@@ -248,13 +247,12 @@ std::shared_ptr<Field> Block::fieldAt(int index) const
248247/* ! Returns the index of the field with the given name. */
249248int Block::findField (const std::string &fieldName) const
250249{
251- int i = 0 ;
252- for (auto field : impl->fields ) {
253- if (field->name () == fieldName)
254- return i;
255- i++;
256- }
257- return -1 ;
250+ auto it = std::find_if (impl->fields .begin (), impl->fields .end (), [fieldName](std::shared_ptr<Field> field) { return field->name () == fieldName; });
251+
252+ if (it == impl->fields .end ())
253+ return -1 ;
254+ else
255+ return it - impl->fields .begin ();
258256}
259257
260258/* ! Returns the index of the field with the given ID. */
You can’t perform that action at this time.
0 commit comments