@@ -37,7 +37,7 @@ using namespace Gambit;
3737// class gbtNodeEntry: Member functions
3838// -----------------------------------------------------------------------
3939
40- gbtNodeEntry::gbtNodeEntry (GameNode p_node)
40+ gbtNodeEntry::gbtNodeEntry (const GameNode & p_node)
4141 : m_node(p_node), m_parent(nullptr ), m_x(-1 ), m_y(-1 ), m_nextMember(nullptr ), m_inSupport(true ),
4242 m_size(20 ), m_token(GBT_NODE_TOKEN_CIRCLE), m_branchStyle(GBT_BRANCH_STYLE_LINE),
4343 m_branchLabel(GBT_BRANCH_LABEL_HORIZONTAL), m_branchLength(0 ), m_sublevel(0 ), m_actionProb(0 )
@@ -58,7 +58,7 @@ int gbtNodeEntry::GetChildNumber() const
5858// Draws the node token itself, as well as the incoming branch
5959// (if not the root node)
6060//
61- void gbtNodeEntry::Draw (wxDC &p_dc, GameNode p_selection, bool p_noHints) const
61+ void gbtNodeEntry::Draw (wxDC &p_dc, const GameNode & p_selection, bool p_noHints) const
6262{
6363 if (m_node->GetParent () && m_inSupport) {
6464 DrawIncomingBranch (p_dc);
@@ -128,8 +128,8 @@ void gbtNodeEntry::DrawIncomingBranch(wxDC &p_dc) const
128128 // Draw in the highlight indicating action probabilities
129129 if (m_actionProb >= Rational (0 )) {
130130 p_dc.SetPen (*wxThePenList->FindOrCreatePen (*wxBLACK, 4 , wxPENSTYLE_SOLID));
131- p_dc.DrawLine (xStart, yStart, xStart + (int )((double )(xEnd - xStart) * ( double ) m_actionProb),
132- yStart + (int )((double )(yEnd - yStart) * ( double ) m_actionProb));
131+ p_dc.DrawLine (xStart, yStart, xStart + (int )((double )(xEnd - xStart) * m_actionProb),
132+ yStart + (int )((double )(yEnd - yStart) * m_actionProb));
133133 }
134134
135135 int textWidth, textHeight;
@@ -307,7 +307,7 @@ bool gbtNodeEntry::NodeHitTest(int p_x, int p_y) const
307307 }
308308
309309 if (m_token == GBT_NODE_TOKEN_LINE) {
310- const int DELTA = 8 ; // a fudge factor for "almost" hitting the node
310+ constexpr int DELTA = 8 ; // a fudge factor for "almost" hitting the node
311311 return (p_y >= m_y - DELTA && p_y <= m_y + DELTA);
312312 }
313313 else {
@@ -385,7 +385,7 @@ GameNode gbtTreeLayout::InfosetHitTest(int p_x, int p_y) const
385385 return nullptr ;
386386}
387387
388- wxString gbtTreeLayout::CreateNodeLabel (const std::shared_ptr<gbtNodeEntry> p_entry,
388+ wxString gbtTreeLayout::CreateNodeLabel (const std::shared_ptr<gbtNodeEntry> & p_entry,
389389 int p_which) const
390390{
391391 const GameNode n = p_entry->GetNode ();
@@ -444,7 +444,7 @@ wxString gbtTreeLayout::CreateNodeLabel(const std::shared_ptr<gbtNodeEntry> p_en
444444 }
445445}
446446
447- wxString gbtTreeLayout::CreateBranchLabel (const std::shared_ptr<gbtNodeEntry> p_entry,
447+ wxString gbtTreeLayout::CreateBranchLabel (const std::shared_ptr<gbtNodeEntry> & p_entry,
448448 int p_which) const
449449{
450450 const GameNode parent = p_entry->GetParent ()->GetNode ();
@@ -490,8 +490,7 @@ wxString gbtTreeLayout::CreateBranchLabel(const std::shared_ptr<gbtNodeEntry> p_
490490
491491std::shared_ptr<gbtNodeEntry> gbtTreeLayout::GetValidParent (const GameNode &e)
492492{
493- auto n = GetNodeEntry (e->GetParent ());
494- if (n) {
493+ if (auto n = GetNodeEntry (e->GetParent ())) {
495494 return n;
496495 }
497496 return GetValidParent (e->GetParent ());
@@ -512,7 +511,7 @@ std::shared_ptr<gbtNodeEntry> gbtTreeLayout::GetValidChild(const GameNode &e)
512511 return nullptr ;
513512}
514513
515- std::shared_ptr<gbtNodeEntry> gbtTreeLayout::GetEntry (const GameNode &p_node) const
514+ std::shared_ptr<gbtNodeEntry> gbtTreeLayout::GetNodeEntry (const GameNode &p_node) const
516515{
517516 for (const auto &entry : m_nodeList) {
518517 if (entry->GetNode () == p_node) {
@@ -524,8 +523,7 @@ std::shared_ptr<gbtNodeEntry> gbtTreeLayout::GetEntry(const GameNode &p_node) co
524523
525524GameNode gbtTreeLayout::PriorSameLevel (const GameNode &p_node) const
526525{
527- auto entry = GetEntry (p_node);
528- if (entry) {
526+ if (auto entry = GetNodeEntry (p_node)) {
529527 auto e = std::next (std::find (m_nodeList.rbegin (), m_nodeList.rend (), entry));
530528 while (e != m_nodeList.rend ()) {
531529 if ((*e)->GetLevel () == entry->GetLevel ()) {
@@ -538,8 +536,7 @@ GameNode gbtTreeLayout::PriorSameLevel(const GameNode &p_node) const
538536
539537GameNode gbtTreeLayout::NextSameLevel (const GameNode &p_node) const
540538{
541- auto entry = GetEntry (p_node);
542- if (entry) {
539+ if (auto entry = GetNodeEntry (p_node)) {
543540 auto e = std::next (std::find (m_nodeList.begin (), m_nodeList.end (), entry));
544541 while (e != m_nodeList.end ()) {
545542 if ((*e)->GetLevel () == entry->GetLevel ()) {
@@ -557,7 +554,7 @@ int gbtTreeLayout::LayoutSubtree(const GameNode &p_node, const BehaviorSupportPr
557554 int y1 = -1 , yn = 0 ;
558555 const gbtStyle &settings = m_doc->GetStyle ();
559556
560- auto entry = GetEntry (p_node);
557+ auto entry = GetNodeEntry (p_node);
561558 entry->SetNextMember (nullptr );
562559 if (m_doc->GetStyle ().RootReachable () && p_node->GetInfoset () &&
563560 !p_node->GetInfoset ()->GetPlayer ()->IsChance ()) {
@@ -580,7 +577,7 @@ int gbtTreeLayout::LayoutSubtree(const GameNode &p_node, const BehaviorSupportPr
580577
581578 if (!p_node->GetPlayer ()->IsChance () && !p_support.Contains (action)) {
582579 (*std::find_if (m_nodeList.begin (), m_nodeList.end (),
583- [&](std::shared_ptr<gbtNodeEntry> e) {
580+ [&](const std::shared_ptr<gbtNodeEntry> & e) {
584581 return e->GetNode () == p_node->GetChild (action);
585582 }))
586583 ->SetInSupport (false );
@@ -633,7 +630,7 @@ int gbtTreeLayout::LayoutSubtree(const GameNode &p_node, const BehaviorSupportPr
633630// Checks if there are any nodes in the same infoset as e that are either
634631// on the same level (if SHOWISET_SAME) or on any level (if SHOWISET_ALL)
635632//
636- std::shared_ptr<gbtNodeEntry> gbtTreeLayout::NextInfoset (std::shared_ptr<gbtNodeEntry> e)
633+ std::shared_ptr<gbtNodeEntry> gbtTreeLayout::NextInfoset (const std::shared_ptr<gbtNodeEntry> & e)
637634{
638635 const gbtStyle &draw_settings = m_doc->GetStyle ();
639636
@@ -660,7 +657,7 @@ std::shared_ptr<gbtNodeEntry> gbtTreeLayout::NextInfoset(std::shared_ptr<gbtNode
660657// infoset node+1. Also lengthens the nodes by the amount of space taken up
661658// by the infoset lines.
662659//
663- void gbtTreeLayout::CheckInfosetEntry (std::shared_ptr<gbtNodeEntry> e)
660+ void gbtTreeLayout::CheckInfosetEntry (const std::shared_ptr<gbtNodeEntry> & e)
664661{
665662 // Check if the infoset this entry belongs to (on this level) has already
666663 // been processed. If so, make this entry->num the same as the one already
0 commit comments