Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made DTL_SEPARATE_SIZE and DTL_CONTEXT_SIZE dynamic. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions dtl/Diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace dtl {
/**
* compose Unified Format Hunks from Shortest Edit Script
*/
void composeUnifiedHunks () {
void composeUnifiedHunks (const long long separateSize = 3, const long long contextSize = 3) {
sesElemVec common[2];
sesElemVec change;
sesElemVec ses_v = ses.getSequence();
Expand Down Expand Up @@ -416,7 +416,7 @@ namespace dtl {
case SES_COMMON :
++b;++d;
if (common[1].empty() && adds.empty() && deletes.empty() && change.empty()) {
if (static_cast<long long>(common[0].size()) < DTL_CONTEXT_SIZE) {
if (static_cast<long long>(common[0].size()) < contextSize) {
if (a == 0 && c == 0) {
if (!wasSwapped()) {
a = einfo.beforeIdx;
Expand All @@ -440,7 +440,7 @@ namespace dtl {
joinSesVec(change, deletes);
joinSesVec(change, adds);
change.push_back(*it);
if (middle >= DTL_SEPARATE_SIZE || l_cnt >= length) {
if (middle >= separateSize || l_cnt >= length) {
isAfter = true;
}
adds.clear();
Expand All @@ -455,26 +455,26 @@ namespace dtl {
if (isAfter && !change.empty()) {
sesElemVec_iter cit = it;
long long cnt = 0;
for (long long i=0;i<DTL_SEPARATE_SIZE && (cit != ses_v.end());++i, ++cit) {
for (long long i=0;i<separateSize && (cit != ses_v.end());++i, ++cit) {
if (cit->second.type == SES_COMMON) {
++cnt;
}
}
if (cnt < DTL_SEPARATE_SIZE && l_cnt < length) {
if (cnt < separateSize && l_cnt < length) {
middle = 0;
isAfter = false;
continue;
}
if (static_cast<long long>(common[0].size()) >= DTL_SEPARATE_SIZE) {
if (static_cast<long long>(common[0].size()) >= separateSize) {
long long c0size = static_cast<long long>(common[0].size());
rotate(common[0].begin(),
common[0].begin() + (size_t)c0size - DTL_SEPARATE_SIZE,
common[0].begin() + (size_t)c0size - separateSize,
common[0].end());
for (long long i=0;i<c0size - DTL_SEPARATE_SIZE;++i) {
for (long long i=0;i<c0size - separateSize;++i) {
common[0].pop_back();
}
a += c0size - DTL_SEPARATE_SIZE;
c += c0size - DTL_SEPARATE_SIZE;
a += c0size - separateSize;
c += c0size - separateSize;
}
if (a == 0) ++a;
if (c == 0) ++c;
Expand Down
3 changes: 0 additions & 3 deletions dtl/variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ namespace dtl {
}
} elemInfo;

const long long DTL_SEPARATE_SIZE = 3;
const long long DTL_CONTEXT_SIZE = 3;

/**
* cordinate for registering route
*/
Expand Down