Skip to content

Commit bea6d54

Browse files
committed
fix #359: Return vectors by reference in Block
1 parent 1aa7756 commit bea6d54

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/scratchcpp/block.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class LIBSCRATCHCPP_EXPORT Block : public Entity
3939
void setParent(std::shared_ptr<Block> block);
4040
void setParentId(const std::string &id);
4141

42-
std::vector<std::shared_ptr<Input>> inputs() const;
42+
const std::vector<std::shared_ptr<Input>> &inputs() const;
4343
int addInput(std::shared_ptr<Input> input);
4444
std::shared_ptr<Input> inputAt(int index) const;
4545
int findInput(const std::string &inputName) const;
4646
Input *findInputById(int id) const;
4747

48-
std::vector<std::shared_ptr<Field>> fields() const;
48+
const std::vector<std::shared_ptr<Field>> &fields() const;
4949
int addField(std::shared_ptr<Field> field);
5050
std::shared_ptr<Field> fieldAt(int index) const;
5151
int findField(const std::string &fieldName) const;

src/scratch/block.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void Block::setParentId(const std::string &id)
155155
}
156156

157157
/*! Returns the list of inputs. */
158-
std::vector<std::shared_ptr<Input>> Block::inputs() const
158+
const std::vector<std::shared_ptr<Input>> &Block::inputs() const
159159
{
160160
return impl->inputs;
161161
}
@@ -217,7 +217,7 @@ void Block::updateInputMap()
217217
}
218218

219219
/*! Returns the list of fields. */
220-
std::vector<std::shared_ptr<Field>> Block::fields() const
220+
const std::vector<std::shared_ptr<Field>> &Block::fields() const
221221
{
222222
return impl->fields;
223223
}

0 commit comments

Comments
 (0)