Skip to content

Commit 6697dcf

Browse files
committed
Engine: Add missing references
1 parent 923a0a8 commit 6697dcf

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/engine/engine.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ std::shared_ptr<IBlockSection> Engine::blockSection(const std::string &opcode) c
322322
}
323323

324324
/*! Returns the list of broadcasts. */
325-
std::vector<std::shared_ptr<Broadcast>> Engine::broadcasts() const
325+
const std::vector<std::shared_ptr<Broadcast>> &Engine::broadcasts() const
326326
{
327327
return m_broadcasts;
328328
}
@@ -375,7 +375,7 @@ void libscratchcpp::Engine::addBroadcastScript(std::shared_ptr<Block> whenReceiv
375375
}
376376

377377
/*! Returns the list of targets. */
378-
std::vector<std::shared_ptr<Target>> Engine::targets() const
378+
const std::vector<std::shared_ptr<Target>> &Engine::targets() const
379379
{
380380
return m_targets;
381381
}
@@ -414,7 +414,7 @@ int Engine::findTarget(const std::string &targetName) const
414414
}
415415

416416
/*! Returns the list of extension names. */
417-
std::vector<std::string> Engine::extensions() const
417+
const std::vector<std::string> &Engine::extensions() const
418418
{
419419
return m_extensions;
420420
}
@@ -445,7 +445,7 @@ const std::unordered_map<std::shared_ptr<Block>, std::shared_ptr<Script>> &Engin
445445
}
446446

447447
/*! Returns the block with the given ID. */
448-
std::shared_ptr<Block> Engine::getBlock(std::string id)
448+
std::shared_ptr<Block> Engine::getBlock(const std::string &id)
449449
{
450450
if (id.empty())
451451
return nullptr;
@@ -460,7 +460,7 @@ std::shared_ptr<Block> Engine::getBlock(std::string id)
460460
}
461461

462462
/*! Returns the variable with the given ID. */
463-
std::shared_ptr<Variable> Engine::getVariable(std::string id)
463+
std::shared_ptr<Variable> Engine::getVariable(const std::string &id)
464464
{
465465
if (id.empty())
466466
return nullptr;
@@ -475,7 +475,7 @@ std::shared_ptr<Variable> Engine::getVariable(std::string id)
475475
}
476476

477477
/*! Returns the Scratch list with the given ID. */
478-
std::shared_ptr<List> Engine::getList(std::string id)
478+
std::shared_ptr<List> Engine::getList(const std::string &id)
479479
{
480480
if (id.empty())
481481
return nullptr;
@@ -490,7 +490,7 @@ std::shared_ptr<List> Engine::getList(std::string id)
490490
}
491491

492492
/*! Returns the broadcast with the given ID. */
493-
std::shared_ptr<Broadcast> Engine::getBroadcast(std::string id)
493+
std::shared_ptr<Broadcast> Engine::getBroadcast(const std::string &id)
494494
{
495495
if (id.empty())
496496
return nullptr;
@@ -503,7 +503,7 @@ std::shared_ptr<Broadcast> Engine::getBroadcast(std::string id)
503503
}
504504

505505
/*! Returns the entity with the given ID. \see IEntity */
506-
std::shared_ptr<IEntity> Engine::getEntity(std::string id)
506+
std::shared_ptr<IEntity> Engine::getEntity(const std::string &id)
507507
{
508508
// Blocks
509509
auto block = getBlock(id);

src/engine/engine.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,30 @@ class LIBSCRATCHCPP_EXPORT Engine
5151
unsigned int functionIndex(BlockFunc f);
5252
std::shared_ptr<IBlockSection> blockSection(const std::string &opcode) const;
5353

54-
std::vector<std::shared_ptr<Broadcast>> broadcasts() const;
54+
const std::vector<std::shared_ptr<Broadcast>> &broadcasts() const;
5555
void setBroadcasts(const std::vector<std::shared_ptr<Broadcast>> &broadcasts);
5656
std::shared_ptr<Broadcast> broadcastAt(int index) const;
5757
int findBroadcast(const std::string &broadcastName) const;
5858
int findBroadcastById(const std::string &broadcastId) const;
5959

6060
void addBroadcastScript(std::shared_ptr<Block> whenReceivedBlock, std::shared_ptr<Broadcast> broadcast);
6161

62-
std::vector<std::shared_ptr<Target>> targets() const;
62+
const std::vector<std::shared_ptr<Target>> &targets() const;
6363
void setTargets(const std::vector<std::shared_ptr<Target>> &newTargets);
6464
Target *targetAt(int index) const;
6565
int findTarget(const std::string &targetName) const;
6666

67-
std::vector<std::string> extensions() const;
67+
const std::vector<std::string> &extensions() const;
6868
void setExtensions(const std::vector<std::string> &newExtensions);
6969

7070
const std::unordered_map<std::shared_ptr<Block>, std::shared_ptr<Script>> &scripts() const;
7171

7272
private:
73-
std::shared_ptr<Block> getBlock(std::string id);
74-
std::shared_ptr<Variable> getVariable(std::string id);
75-
std::shared_ptr<List> getList(std::string id);
76-
std::shared_ptr<Broadcast> getBroadcast(std::string id);
77-
std::shared_ptr<IEntity> getEntity(std::string id);
73+
std::shared_ptr<Block> getBlock(const std::string &id);
74+
std::shared_ptr<Variable> getVariable(const std::string &id);
75+
std::shared_ptr<List> getList(const std::string &id);
76+
std::shared_ptr<Broadcast> getBroadcast(const std::string &id);
77+
std::shared_ptr<IEntity> getEntity(const std::string &id);
7878
std::vector<std::shared_ptr<IBlockSection>> m_sections;
7979
std::vector<std::shared_ptr<Target>> m_targets;
8080
std::vector<std::shared_ptr<Broadcast>> m_broadcasts;

0 commit comments

Comments
 (0)