Skip to content

Commit 13c363f

Browse files
committed
Block: Return by reference where possible
1 parent c1004e9 commit 13c363f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/scratchcpp/block.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class LIBSCRATCHCPP_EXPORT Block : public Entity
2727

2828
void compile(Compiler *compiler);
2929

30-
std::string opcode() const;
30+
const std::string &opcode() const;
3131

3232
std::shared_ptr<Block> next() const;
33-
std::string nextId() const;
33+
const std::string &nextId() const;
3434
void setNext(std::shared_ptr<Block> block);
3535
void setNextId(const std::string &nextId);
3636

3737
std::shared_ptr<Block> parent() const;
38-
std::string parentId() const;
38+
const std::string &parentId() const;
3939
void setParent(std::shared_ptr<Block> block);
4040
void setParentId(const std::string &id);
4141

@@ -57,7 +57,7 @@ class LIBSCRATCHCPP_EXPORT Block : public Entity
5757
bool topLevel() const;
5858

5959
std::shared_ptr<Comment> comment() const;
60-
std::string commentId() const;
60+
const std::string &commentId() const;
6161
void setComment(std::shared_ptr<Comment> comment);
6262
void setCommentId(const std::string &commentId);
6363

src/scratch/block.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void Block::compile(Compiler *compiler)
2424
}
2525

2626
/*! Returns the opcode. */
27-
std::string Block::opcode() const
27+
const std::string &Block::opcode() const
2828
{
2929
return impl->opcode;
3030
}
@@ -101,7 +101,7 @@ std::shared_ptr<Block> Block::next() const
101101
}
102102

103103
/*! Returns the ID of the next block. */
104-
std::string Block::nextId() const
104+
const std::string &Block::nextId() const
105105
{
106106
return impl->nextId;
107107
}
@@ -131,7 +131,7 @@ std::shared_ptr<Block> Block::parent() const
131131
}
132132

133133
/*! Returns the ID of the parent block. */
134-
std::string Block::parentId() const
134+
const std::string &Block::parentId() const
135135
{
136136
return impl->parentId;
137137
}
@@ -301,7 +301,7 @@ std::shared_ptr<Comment> Block::comment() const
301301
}
302302

303303
/*! Returns the ID of the comment which is attached to this block. */
304-
std::string Block::commentId() const
304+
const std::string &Block::commentId() const
305305
{
306306
return impl->commentId;
307307
}

0 commit comments

Comments
 (0)