Improved reply tread generation speed and floating thread logic.

This commit is contained in:
Ianos Gnatiuc 2006-05-17 21:01:10 +00:00
parent 508dd05f5e
commit 217dc2743a
3 changed files with 85 additions and 72 deletions

View File

@ -10,6 +10,9 @@ _____________________________________________________________________________
 ¬¥β<C2A5>¨ ¤«ο GoldED+ 1.1.5, /snapshot/  ¬¥β<C2A5>¨ ¤«ο GoldED+ 1.1.5, /snapshot/
_____________________________________________________________________________ _____________________________________________________________________________
+ “«ãç襭  «®£¨ª  "¯« ¢ îé¨å" ¤¥à¥¢ì¥¢ ®â¢¥â®¢ (á¬. ReplyLinkFloat).
+ „¥à¥¢® ®â¢¥â®¢ £¥­¥à¨àã¥âáï ­¥¬­®£® ¡ëáâ॥.
‘­ ―θ®β ®β 15 ¬ ο 2006. ‘­ ―θ®β ®β 15 ¬ ο 2006.
+ <20>¥®£ΰ ­¨η¥­­®¥ η¨α«® «¨­<C2A8>®Ά ­  ―¨α쬮 Ά ¤¥ΰ¥Ά¥ ®βΆ¥β®Ά (΅λ«® 30). + <20>¥®£ΰ ­¨η¥­­®¥ η¨α«® «¨­<C2A8>®Ά ­  ―¨α쬮 Ά ¤¥ΰ¥Ά¥ ®βΆ¥β®Ά (΅λ«® 30).

View File

@ -10,6 +10,10 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/ Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________ ______________________________________________________________________
+ Improved floating reply threads logic (see ReplyLinkFloat).
+ Reply tread is generated a bit faster.
= Snapshot for the May 15, 2006. = Snapshot for the May 15, 2006.
+ Unlimited reply link chain (max was 30 replies). + Unlimited reply link chain (max was 30 replies).

View File

@ -726,12 +726,14 @@ private:
gwindow window; gwindow window;
GMsg msg; GMsg msg;
std::vector<ThreadEntry> list;
ThreadEntry t; ThreadEntry t;
std::vector<ThreadEntry> list;
std::vector<std::string> tree;
void BuildThreadIndex(dword msgno); void BuildThreadIndex(dword msgno);
void recursive_build(uint32_t msgn, uint32_t rn, uint32_t level); void recursive_build(uint32_t msgn, uint32_t rn, uint32_t level, uint32_t index);
void GenTree(char* buf2, int idx, uint32_t maxlev); void GenTree(int idx);
void update_title(); void update_title();
bool NextThread(bool next); bool NextThread(bool next);
@ -840,7 +842,15 @@ void GThreadlist::close() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void GThreadlist::GenTree(char* buf, int idx, uint32_t maxlev) { void GThreadlist::GenTree(int idx)
{
if (tree.size() > idx)
{
if (tree[idx].size())
return;
}
else
tree.resize(idx+1);
#ifdef KOI8 #ifdef KOI8
static char graph[4]="†„<EFBFBD>"; static char graph[4]="†„<EFBFBD>";
@ -848,7 +858,8 @@ void GThreadlist::GenTree(char* buf, int idx, uint32_t maxlev) {
static char graph_ibmpc[4]="ÃÀ³"; static char graph_ibmpc[4]="ÃÀ³";
static char graph[4]=""; static char graph[4]="";
if(graph[0] == NUL) { if(graph[0] == NUL)
{
int table = LoadCharset(NULL, NULL, 1); int table = LoadCharset(NULL, NULL, 1);
int level = LoadCharset(get_dos_charset(CFG->xlatlocalset), CFG->xlatlocalset); int level = LoadCharset(get_dos_charset(CFG->xlatlocalset), CFG->xlatlocalset);
XlatStr(graph, graph_ibmpc, level, CharTable); XlatStr(graph, graph_ibmpc, level, CharTable);
@ -856,47 +867,43 @@ void GThreadlist::GenTree(char* buf, int idx, uint32_t maxlev) {
LoadCharset(CFG->xlatimport, CFG->xlatlocalset); LoadCharset(CFG->xlatimport, CFG->xlatlocalset);
else else
LoadCharset(CFG->xlatcharset[table].imp, CFG->xlatcharset[table].exp); LoadCharset(CFG->xlatcharset[table].imp, CFG->xlatcharset[table].exp);
#if defined(__UNIX__) && !defined(__USE_NCURSES__)
gvid_boxcvt(graph);
#endif
} }
#endif #endif
ThreadEntry te = list[idx]; ThreadEntry te = list[idx];
buf[0] = ' '; if (te.level == 0)
{
if(te.level == 0) { tree[idx] = " ";
buf[1] = NUL;
return; return;
} }
if(te.level < maxlev) { tree[idx].resize((te.level-1)*2+4, ' ');
buf[(te.level-1)*2+1] = (te.replynext) ? graph[0] : graph[1];
buf[(te.level-1)*2+2] = ' ';
buf[(te.level-1)*2+3] = NUL;
}
while(te.replyto) { tree[idx][(te.level-1)*2+1] = (te.replynext) ? graph[0] : graph[1];
tree[idx][(te.level-1)*2+3] = 0;
while (te.replyto)
{
te = list[te.replytoindex]; te = list[te.replytoindex];
if((te.level != 0) and (te.level < maxlev)) { if (te.level != 0)
buf[(te.level-1)*2+1] = (te.replynext) ? graph[2] : ' '; {
buf[(te.level-1)*2+2] = ' '; if (te.replynext)
tree[idx][(te.level-1)*2+1] = graph[2];
} }
} }
buf[maxlev*2+1] = NUL;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void GThreadlist::print_line(uint idx, uint pos, bool isbar) { void GThreadlist::print_line(uint idx, uint pos, bool isbar)
{
char buf[256]; char buf[256];
uint32_t maxlev = (100*window.width()+h_offset+1)/2;
#if defined(__USE_ALLOCA__)
char *buf2 = (char*)alloca(maxlev*2+2);
#else
__extension__ char buf2[maxlev*2+2];
#endif
t = list[idx]; t = list[idx];
size_t tdlen = xlen - ((AA->Msglistdate() == MSGLISTDATE_NONE) ? 8 : 18); size_t tdlen = xlen - ((AA->Msglistdate() == MSGLISTDATE_NONE) ? 8 : 18);
@ -922,15 +929,7 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
attrh = hattr; attrh = hattr;
} }
GenTree(buf2, idx, maxlev); char marks[3] = " ";
#if defined(__UNIX__) && !defined(__USE_NCURSES__)
gvid_boxcvt(buf2);
#endif
char marks[3];
strcpy(marks, " ");
if(AA->bookmark == t.msgno) if(AA->bookmark == t.msgno)
marks[0] = MMRK_BOOK; marks[0] = MMRK_BOOK;
@ -969,7 +968,11 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
window.prints(pos, 0, isbar ? sattr : attrw, buf); window.prints(pos, 0, isbar ? sattr : attrw, buf);
window.prints(pos, 6, isbar ? sattr : hattr, marks); window.prints(pos, 6, isbar ? sattr : hattr, marks);
GenTree(idx);
const char* buf2 = tree[idx].c_str();
size_t buf2len = strlen(buf2); size_t buf2len = strlen(buf2);
if (buf2len > h_offset) if (buf2len > h_offset)
{ {
strxcpy(buf, &buf2[h_offset], tdlen); strxcpy(buf, &buf2[h_offset], tdlen);
@ -990,9 +993,23 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
{ {
size_t bylen = strlen(msg.By()); size_t bylen = strlen(msg.By());
if ((buf2len + bylen) > (tdlen - 1)) if ((buf2len + bylen) > (tdlen - 1))
new_hoffset = (buf2len + bylen)-tdlen+1; {
uint offset = (buf2len + bylen) - tdlen + 1;
offset = (offset/10 + 1)*10;
if (offset >= new_hoffset)
new_hoffset = offset;
else else
new_hoffset = 0; {
while ((new_hoffset - offset) >= tdlen*2/3)
new_hoffset -= 10;
}
}
else
{
while (buf2len < new_hoffset)
new_hoffset -= 10;
}
attr = sattr; attr = sattr;
} }
@ -1016,45 +1033,32 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void GThreadlist::recursive_build(uint32_t msgn, uint32_t rn, uint32_t level) { void GThreadlist::recursive_build(uint32_t msgn, uint32_t rn, uint32_t level, uint32_t index)
{
uint32_t oldmsgno = msg.msgno; uint32_t oldmsgno = msg.msgno;
if(AA->Msgn.ToReln(msgn) and AA->LoadHdr(&msg, msgn)) { if (AA->Msgn.ToReln(msgn) and AA->LoadHdr(&msg, msgn))
{
t.msgno = msgn; t.msgno = msgn;
t.replyto = msg.link.to(); t.replyto = msg.link.to();
t.reply1st = msg.link.first(); t.reply1st = msg.link.first();
t.replynext = rn; t.replynext = rn;
t.level = level; t.level = level++;
t.replytoindex = 0; t.replytoindex = index;
if(not AA->Msgn.ToReln(t.replyto)) if (!AA->Msgn.ToReln(t.replyto)) t.replyto = 0;
t.replyto = 0; if (!AA->Msgn.ToReln(t.reply1st)) t.reply1st = 0;
if(not AA->Msgn.ToReln(t.reply1st)) if (!AA->Msgn.ToReln(t.replynext)) t.replynext = 0;
t.reply1st = 0;
if(not AA->Msgn.ToReln(t.replynext))
t.replynext = 0;
uint j, list_size = list.size();
bool found = false;
for(j=0; j<list_size; j++) {
if(list[j].msgno == t.replyto) {
t.replytoindex = j;
found = true;
break;
}
}
if (found or (list_size == 0))
list.push_back(t); list.push_back(t);
index = list.size() - 1;
recursive_build(msg.link.first(), msg.link.list(0), level+1); recursive_build(msg.link.first(), msg.link.list(0), level, index);
for(size_t n = 0, max = msg.link.list_max(); n < max; n++) for (size_t n = 0, max = msg.link.list_max(); n < max; n++)
{ {
if (msg.link.list(n)) if (msg.link.list(n))
recursive_build(msg.link.list(n), msg.link.list(n+1), level+1); recursive_build(msg.link.list(n), msg.link.list(n+1), level, index);
} }
AA->LoadHdr(&msg, oldmsgno); AA->LoadHdr(&msg, oldmsgno);
@ -1064,12 +1068,14 @@ void GThreadlist::recursive_build(uint32_t msgn, uint32_t rn, uint32_t level) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void GThreadlist::BuildThreadIndex(dword msgn) { void GThreadlist::BuildThreadIndex(dword msgn)
{
w_info(LNG->Wait); w_info(LNG->Wait);
index = maximum_index = position = maximum_position = 0; index = maximum_index = position = maximum_position = 0;
list.clear(); list.clear();
tree.clear();
AA->LoadHdr(&msg, msgn); AA->LoadHdr(&msg, msgn);
@ -1090,7 +1096,7 @@ void GThreadlist::BuildThreadIndex(dword msgn) {
msgno = msg.link.to(); msgno = msg.link.to();
} }
recursive_build(msg.msgno, 0, 0); recursive_build(msg.msgno, 0, 0, 0);
w_info(NULL); w_info(NULL);