Commit 6662d19a authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(adjust_read): Aim at setting first_read of the first range to 1, even

	if that is lower than the first currently existing text in the
	conference.  Make the code that tries to extend ranges towards
	higher numbers more efficient -- no loop is needed, since
	l2g_next_key can be used.  Removed some dead code.
parent a3d02cc3
/*
* $Id: membership.c,v 0.76 2002/11/10 14:10:52 ceder Exp $
* $Id: membership.c,v 0.77 2002/11/11 23:44:19 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -392,6 +392,9 @@ adjust_read(Membership *m,
Local_text_no conf_max; /* Highest used local_text_no in conf */
Local_text_no conf_min; /* Lowest used local_text_no in conf */
Local_text_no past_block; /* The next local_text_no after the current block. */
Local_text_no limit;
/* If nothing is marked as read, there is nothing to adjust. */
if (m->no_of_read_ranges == 0)
return;
......@@ -449,20 +452,25 @@ adjust_read(Membership *m,
next = NULL;
/* Try to lower first_read. */
while (ptr->first_read > conf_min
while (ptr->first_read > 1
&& (prev == NULL || prev->last_read + 1 < ptr->first_read)
&& l2g_lookup(&conf->texts, ptr->first_read - 1) == 0)
{
ptr->first_read--;
if (ptr->first_read < conf_min)
ptr->first_read = 1;
}
/* Try to raise last_read. */
while (ptr->last_read < conf_max - 1
&& (next == NULL || ptr->last_read < next->first_read - 1)
&& l2g_lookup(&conf->texts, ptr->last_read + 1) == 0)
{
ptr->last_read++;
}
/* Raise last_read past any deleted texts. */
past_block = l2g_next_key(&conf->texts, ptr->last_read);
if (next != NULL)
limit = next->first_read;
else
limit = conf_max;
if (past_block == 0 || past_block > limit)
past_block = limit;
ptr->last_read = past_block - 1;
}
/* Join any ranges that became adjacent. */
......@@ -572,16 +580,12 @@ insert_loc_no(Local_text_no text,
if (text == lo->first_read - 1)
{
if (lo != begin && (lo-1)->last_read == text)
return FAILURE; /* This text was already read. */
lo->first_read = text;
return OK;
}
if (text == lo->last_read + 1)
{
if (lo != end && lo + 1 != end && (lo+1)->first_read == text)
return FAILURE; /* This text was already read. */
lo->last_read = text;
return OK;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment