deleted dead code / unnecessary comments.

This commit is contained in:
Sears Russell 2007-02-07 03:06:35 +00:00
parent d2d631ff30
commit 4ae4ad54d7

View file

@ -201,7 +201,6 @@ static inline long roundUp(long x, long quant) {
static void pinnedRanges(const rangeTracker * rt, const range * request, rangeTracker * ret, int delta) {
transition key;
// we will start looking at the tree at the first transition after key.pos.
// DEL OLD COMMENT: the -1 gives us >= instead of > when we pass RB_LUGREAT into rblookup.
key.pos = roundDown(request->start, rt->quantization);
const transition * t = &key;
@ -215,7 +214,6 @@ static void pinnedRanges(const rangeTracker * rt, const range * request, rangeTr
while((t = rblookup(RB_LUGREAT, t, rt->ranges))) {
assert(t->delta);
// printf("%s\n", transitionToString(t));
if(t->pos >= expanded_range.stop) {
if(in_range) {
assert(t->pins);
@ -288,171 +286,10 @@ static void pinnedRanges(const rangeTracker * rt, const range * request, rangeTr
}
//#define DBGPINS(...) printf(__VA_ARGS__)
#define DBGPINS(...)
/**
@return a set of ranges that are pinned, and that overlap the request range.
*/
static rangeTracker * pinnedRangesOLD(const rangeTracker * rt, const range * request, rangeTracker * ret, int delta) {
transition key;
const transition * t;
DBGPINS("Call ");
key.pos = roundDown(request->start, rt->quantization);
t = rblookup(RB_LUGTEQ, &key, rt->ranges);
if(!t) {
DBGPINS("at End\n");
// No ranges after request->start, so no ranges can overlap.
return ret;
}
long range_start;
// zero if we just encountered the end of a range. The range runs from
// range_start to putative_range_stop. It is possible that a new range
// begins on the page that putative_range_stop falls on, so we do not
// output the range without looking at the next transition.
int in_range;
// This is only meaningful if in_range = 0.
long putative_range_stop;
if(t) {
DBGPINS("T %ld", t->pos);
if(roundDown(t->pos, rt->quantization) >= roundUp(request->stop, rt->quantization)) {
if(t->pins) {
// entire range is pinned.
range tmp_r;
tmp_r.start = roundDown(request->start, rt->quantization);
tmp_r.stop = roundUp(request->stop, rt->quantization);
assert(tmp_r.start >= roundDown(request->start, rt->quantization) && tmp_r.stop <= roundUp(request->stop, rt->quantization));
rangeTrackerDelta(ret, &tmp_r, delta);
// DBGPINS("0 %s\n", rangeToString(&tmp_r));
} else {
// none of the range is pinned.
}
return ret;
} else if(t->pins) {
DBGPINS("startPin ");
// The beginning of request is a range.
range_start = roundDown(request->start, rt->quantization);
if(0 == t->pins + t->delta) {
DBGPINS("!in ");
in_range = 0;
// even though we're not in range, we need to see if the next
// transition starts a range on the same page before returning a
// new range.
putative_range_stop = roundUp(t->pos, rt->quantization);
} else {
DBGPINS("in ");
in_range = 1;
}
} else {
DBGPINS("start!Pin ");
// The beginning of the request is not a range.
range_start = roundDown(t->pos, rt->quantization);
DBGPINS("A ");
in_range = 1;
assert(t->delta);
}
} else {
DBGPINS("!T ");
}
while((t = rblookup(RB_LUGREAT, t, rt->ranges))) {
DBGPINS("W %ld", t->pos);
assert(t->delta);
if(roundUp(t->pos, rt->quantization) >= roundUp(request->stop, rt->quantization)) {
DBGPINS("Break ");
if(in_range) {
assert(t->pins);
// if we're in range, part of the last page must be pinned.
in_range = 0;
putative_range_stop = roundUp(request->stop, rt->quantization);
} else {
// deal with range that ended before this transition.
range tmp_r;
assert(t->pins == 0);
if(roundUp(putative_range_stop, rt->quantization) < roundDown(t->pos, rt->quantization)) {
// There is a gap between the last range and this range.
tmp_r.start = range_start;
tmp_r.stop = putative_range_stop;
if(tmp_r.start != tmp_r.stop) {
rangeTrackerDelta(ret, &tmp_r, delta);
}
// is this transition in the last page? If so, part of the last page must be pinned.
if(t->pos < roundUp(request->stop, rt->quantization)) {
// in_range == 0
range_start = roundDown(t->pos, rt->quantization);
putative_range_stop = roundUp(request->stop, rt->quantization);
} else {
in_range = 2;
}
} else {
// There is no gap between the last range and this range.
putative_range_stop = roundUp(request->stop, rt->quantization);
}
}
break;
}
if(t->pins) {
DBGPINS("P ");
assert(in_range);
if(!(t->pins + t->delta)) {
putative_range_stop = roundUp(t->pos, rt->quantization);
in_range = 0;
}
} else { // ! t->pins
DBGPINS("!P ");
assert(!in_range);
if(putative_range_stop < roundDown(t->pos, rt->quantization)) {
// output a new range
range tmp_r;
tmp_r.start = range_start;
tmp_r.stop = putative_range_stop;
if(tmp_r.start != tmp_r.stop) {
assert(tmp_r.start >= roundDown(request->start, rt->quantization) && tmp_r.stop <= roundUp(request->stop, rt->quantization));
rangeTrackerDelta(ret, &tmp_r, delta);
// DBGPINS("1 %s\n", rangeToString(&tmp_r));
}
range_start = roundDown(t->pos, rt->quantization);
} else {
// extend old range.
}
in_range = 1;
}
}
assert(in_range==0 || in_range ==2);
if(!in_range) {
range tmp_r;
tmp_r.start = range_start;
tmp_r.stop = putative_range_stop;
if(tmp_r.start != tmp_r.stop) {
DBGPINS("2 ");
assert(tmp_r.start >= roundDown(request->start, rt->quantization) && tmp_r.stop <= roundUp(request->stop, rt->quantization));
rangeTrackerDelta(ret, &tmp_r, delta);
// DBGPINS("2 %s\n", rangeToString(&tmp_r));
}
}
DBGPINS("\n");
return ret;
}
range ** rangeTrackerAdd(rangeTracker * rt, const range * rng) {
// printf("pinnedRanges before add %s\n", rangeToString(rng));
rangeTracker * ret = rangeTrackerInit(rt->quantization);
pinnedRanges(rt, rng, ret, 1);
rangeTrackerDelta(rt, rng, 1);
// printf("pinnedRanges after add\n");
rangeTracker * ret2 = rangeTrackerInit(rt->quantization);
pinnedRanges(rt, rng, ret2, 1);
@ -481,35 +318,6 @@ range ** rangeTrackerAdd(rangeTracker * rt, const range * rng) {
rangeTrackerDeinit(ret2);
return ret_arry;
/* // Need to return pinned ranges that overlap r.
transition key;
const transition * t;
key.pos = rng->start;
t = rblookup(RB_LULTEQ, &key, rt->ranges); // could be less than if the new range touches an existing range.
assert(t);
range r;
int in_range = 1;
r.start = roundDown(t->pos, rt->quantization);
while((t = rblookup(RB_LUGREAT, t, rt->ranges))) {
if(!(t->pins + t->delta)) {
assert(in_range);
in_range = 0;
r.stop = roundUp(t->pos, rt->quantization);
// printf("add range: [%lld-%lld]\n", (long long)r.start, (long long)r.stop);
} else if(!in_range) {
assert(t->pins == 0);
in_range = 1;
r.start = roundDown(t->pos, rt->quantization);
}
if(t->pos >= rng->stop) { break; }
} */
}
/**
@ -519,10 +327,8 @@ range ** rangeTrackerAdd(rangeTracker * rt, const range * rng) {
range ** rangeTrackerRemove(rangeTracker * rt, const range * rang) {
rangeTracker * ret = rangeTrackerInit(rt->quantization);
// printf("pinnedRanges, before del %s\n", rangeToString(rang));
pinnedRanges(rt, rang, ret, 1);
rangeTrackerDelta(rt, rang, -1);
// printf("pinnedRanges, after del\n");
pinnedRanges(rt, rang, ret, -1);
range ** ret_arry = rangeTrackerToArray(ret);
@ -536,77 +342,6 @@ range ** rangeTrackerRemove(rangeTracker * rt, const range * rang) {
return ret_arry;
/* // Need to return completely unpinned ranges that overlap r.
range bigger;
bigger.start = roundDown(rang->start, rt->quantization);
bigger.stop = roundUp(rang->stop, rt->quantization);
transition key;
key.pos = bigger.start;
int unpinned_range = 0;
range r;
const transition * t = RB_ENTRY(lookup)(RB_LUGTEQ, &key, rt->ranges);
long last_end = bigger.start;
// special case beginning of range
if(! t) {
t = RB_ENTRY(lookup)(RB_LULESS, &key, rt->ranges);
if(!t || 0 == t->pins + t->delta) {
// printf("A %s\n", rangeToString(&bigger));
return;
}
} else if(t->pins == 0) {
r.start = bigger.start;
r.stop = roundDown(t->pos, rt->quantization);
if(r.start < r.stop) {
// printf("0 %s\n", rangeToString(&r));
}
unpinned_range = 1;
assert(0 != t->pins + t->delta);
t = RB_ENTRY(lookup)(RB_LUGREAT, t, rt->ranges);
}
if(t) {
unpinned_range = (0 == t->pins + t->delta);
}
while(t) {
if(t->pins == 0) {
// XXX don't care if range bleeds outside of initially pinned range (for now; the difference could be huge in sparse applications)
r.start = roundUp(last_end, rt->quantization);
r.stop = roundDown(t->pos, rt->quantization);
assert(unpinned_range);
if(r.start < r.stop) {
// printf("B %s\n", rangeToString(&r));
} else {
// printf(".. %s bigger = %s\n", rangeToString(&r), rangeToString(&bigger));
}
}
// break after processing transition that runs over the edge...
if(t->pos >= bigger.stop) { break; }
last_end = t->pos;
unpinned_range = (0 == t->pins + t->delta);
t = RB_ENTRY(lookup)(RB_LUGREAT, t, rt->ranges);
}
if(! t && unpinned_range) {
r.start = roundUp(last_end, rt->quantization);
r.stop = bigger.stop;
if(r.start < r.stop) {
// printf("C %s\n", rangeToString(&r));
}
}
// plan: (1) Write roundDown, roundUp macros
// enumerate pinned pages before and after operation. (Note that we need to round down and up to get stuff outside the range, but on common pages)
// return before - after, or after - before, depending on whether this is an add or a remove.
*/
}
const transition ** rangeTrackerEnumerate(rangeTracker * rt) {