Skip to content

Commit

Permalink
use reference rather than pointer to tps
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuhoang committed Aug 17, 2016
1 parent a15997c commit 5054aa0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contrib/moses2/SCFG/Manager.cpp
Expand Up @@ -232,7 +232,7 @@ void Manager::CreateQueue(
{
MemPool &pool = GetPool();

SeenPosition *seenItem = new (pool.Allocate<SeenPosition>()) SeenPosition(pool, symbolBind, &tps, symbolBind.numNT);
SeenPosition *seenItem = new (pool.Allocate<SeenPosition>()) SeenPosition(pool, symbolBind, tps, symbolBind.numNT);
bool unseen = m_seenPositions.Add(seenItem);
assert(unseen);

Expand Down
14 changes: 7 additions & 7 deletions contrib/moses2/SCFG/Misc.cpp
Expand Up @@ -21,7 +21,7 @@ namespace SCFG
////////////////////////////////////////////////////////
SeenPosition::SeenPosition(MemPool &pool,
const SymbolBind &vSymbolBind,
const SCFG::TargetPhrases *vtps,
const SCFG::TargetPhrases &vtps,
size_t numNT)
:symbolBind(vSymbolBind)
,tps(vtps)
Expand All @@ -32,7 +32,7 @@ SeenPosition::SeenPosition(MemPool &pool,

SeenPosition::SeenPosition(MemPool &pool,
const SymbolBind &vSymbolBind,
const SCFG::TargetPhrases *vtps,
const SCFG::TargetPhrases &vtps,
size_t vtpInd,
const Vector<size_t> &vhypoIndColl)
:symbolBind(vSymbolBind)
Expand All @@ -48,7 +48,7 @@ SeenPosition::SeenPosition(MemPool &pool,
std::string SeenPosition::Debug(const System &system) const
{
stringstream out;
out << tps << " " << tpInd << " ";
out << &tps << " " << tpInd << " ";

for (size_t i = 0; i < hypoIndColl.size(); ++i) {
out << hypoIndColl[i] << " ";
Expand All @@ -63,7 +63,7 @@ bool SeenPosition::operator==(const SeenPosition &compare) const
return false;
}

if (tps != compare.tps) {
if (&tps != &compare.tps) {
return false;
}

Expand All @@ -81,7 +81,7 @@ bool SeenPosition::operator==(const SeenPosition &compare) const
size_t SeenPosition::hash() const
{
size_t ret = (size_t) &symbolBind;
boost::hash_combine(ret, tps);
boost::hash_combine(ret, &tps);
boost::hash_combine(ret, tpInd);
boost::hash_combine(ret, hypoIndColl);
return ret;
Expand Down Expand Up @@ -175,7 +175,7 @@ void QueueItem::CreateNext(
if (tpInd + 1 < tps->GetSize()) {

const SCFG::TargetPhraseImpl &tp = (*tps)[tpInd + 1];
SeenPosition *seenItem = new (mgrPool.Allocate<SeenPosition>()) SeenPosition(mgrPool, *symbolBind, tps, tpInd + 1, *m_hypoIndColl);
SeenPosition *seenItem = new (mgrPool.Allocate<SeenPosition>()) SeenPosition(mgrPool, *symbolBind, *tps, tpInd + 1, *m_hypoIndColl);
bool unseen = seenPositions.Add(seenItem);

if (unseen) {
Expand All @@ -196,7 +196,7 @@ void QueueItem::CreateNext(
size_t hypoInd = (*m_hypoIndColl)[i] + 1; // increment hypo

if (hypoInd < hypos.size()) {
SeenPosition *seenItem = new (mgrPool.Allocate<SeenPosition>()) SeenPosition(mgrPool, *symbolBind, tps, tpInd, *m_hypoIndColl);
SeenPosition *seenItem = new (mgrPool.Allocate<SeenPosition>()) SeenPosition(mgrPool, *symbolBind, *tps, tpInd, *m_hypoIndColl);
seenItem->hypoIndColl[i] = hypoInd;
bool unseen = seenPositions.Add(seenItem);

Expand Down
6 changes: 3 additions & 3 deletions contrib/moses2/SCFG/Misc.h
Expand Up @@ -27,17 +27,17 @@ class SeenPosition
{
public:
const SymbolBind &symbolBind;
const SCFG::TargetPhrases *tps;
const SCFG::TargetPhrases &tps;
size_t tpInd;
Vector<size_t> hypoIndColl;

SeenPosition(MemPool &pool,
const SymbolBind &vSymbolBind,
const SCFG::TargetPhrases *vtps,
const SCFG::TargetPhrases &vtps,
size_t numNT);
SeenPosition(MemPool &pool,
const SymbolBind &vSymbolBind,
const SCFG::TargetPhrases *vtps,
const SCFG::TargetPhrases &vtps,
size_t vtpInd,
const Vector<size_t> &vhypoIndColl);

Expand Down

0 comments on commit 5054aa0

Please sign in to comment.