Small code refactoring.
This commit is contained in:
parent
ec1bc5cfca
commit
0b1984978a
|
@ -47,6 +47,10 @@ struct Tag {
|
|||
bool operator != ( const Tag& r ) const { return locality!=r.locality || id!=r.id; }
|
||||
bool operator < ( const Tag& r ) const { return locality < r.locality || (locality == r.locality && id < r.id); }
|
||||
|
||||
int toTagDataIndex() {
|
||||
return locality >= 0 ? 2 * locality : 1 - (2 * locality);
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
return format("%d:%d", locality, id);
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ struct ILogSystem {
|
|||
virtual bool hasMessage() = 0;
|
||||
|
||||
//pre: only callable if hasMessage() returns true
|
||||
//return the tags associated with the message for teh current sequence
|
||||
//return the tags associated with the message for the current sequence
|
||||
virtual const std::vector<Tag>& getTags() = 0;
|
||||
|
||||
//pre: only callable if hasMessage() returns true
|
||||
|
|
|
@ -312,7 +312,7 @@ struct LogSystemConfig {
|
|||
}
|
||||
|
||||
for( auto& i : r.tLogs ) {
|
||||
for( auto& j : oldTLogs[0].tLogs ) {
|
||||
for( auto& j : oldTLogs[0].tLogs ) {
|
||||
if( i.isEqualIds(j) ) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ struct LogData : NonCopyable, public ReferenceCounted<LogData> {
|
|||
int unpoppedRecoveredTags;
|
||||
|
||||
Reference<TagData> getTagData(Tag tag) {
|
||||
int idx = tag.locality >= 0 ? 2*tag.locality : 1-(2*tag.locality);
|
||||
int idx = tag.toTagDataIndex();
|
||||
if(idx >= tag_data.size()) {
|
||||
tag_data.resize(idx+1);
|
||||
}
|
||||
|
@ -389,8 +389,7 @@ struct LogData : NonCopyable, public ReferenceCounted<LogData> {
|
|||
popped = recoveredAt + 1;
|
||||
}
|
||||
Reference<TagData> newTagData = Reference<TagData>( new TagData(tag, popped, nothingPersistent, poppedRecently, unpoppedRecovered) );
|
||||
int idx = tag.locality >= 0 ? 2*tag.locality : 1-(2*tag.locality);
|
||||
tag_data[idx][tag.id] = newTagData;
|
||||
tag_data[tag.toTagDataIndex()][tag.id] = newTagData;
|
||||
return newTagData;
|
||||
}
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ struct LogData : NonCopyable, public ReferenceCounted<LogData> {
|
|||
int unpoppedRecoveredTags;
|
||||
|
||||
Reference<TagData> getTagData(Tag tag) {
|
||||
int idx = tag.locality >= 0 ? 2*tag.locality : 1-(2*tag.locality);
|
||||
int idx = tag.toTagDataIndex();
|
||||
if(idx >= tag_data.size()) {
|
||||
tag_data.resize(idx+1);
|
||||
}
|
||||
|
@ -445,8 +445,7 @@ struct LogData : NonCopyable, public ReferenceCounted<LogData> {
|
|||
popped = recoveredAt + 1;
|
||||
}
|
||||
Reference<TagData> newTagData = Reference<TagData>( new TagData(tag, popped, 0, nothingPersistent, poppedRecently, unpoppedRecovered) );
|
||||
int idx = tag.locality >= 0 ? 2*tag.locality : 1-(2*tag.locality);
|
||||
tag_data[idx][tag.id] = newTagData;
|
||||
tag_data[tag.toTagDataIndex()][tag.id] = newTagData;
|
||||
return newTagData;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue