Skip to content

Commit

Permalink
[GreenPad] only ReParse lines after loaded completely
Browse files Browse the repository at this point in the history
this may improve loading time when there is lots of super-long lines in file.

ported from RamonUnch/GreenPad@ced7a1a
  • Loading branch information
roytam1 committed Nov 11, 2023
1 parent 9d490f7 commit 246df33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion GreenPad/editwing/ip_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class DocImpl : public Object, EzLockable, Runnable

// 挿入・削除作業
bool InsertingOperation(
DPos& stt, const unicode* str, ulong len, DPos& undoend );
DPos& stt, const unicode* str, ulong len, DPos& undoend, bool reparse=true );
bool DeletingOperation(
DPos& stt, DPos& end, unicode*& undobuf, ulong& undosiz );

Expand Down
24 changes: 10 additions & 14 deletions GreenPad/editwing/ip_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ bool DocImpl::DeletingOperation
}

bool DocImpl::InsertingOperation
( DPos& s, const unicode* str, ulong len, DPos& e )
( DPos& s, const unicode* str, ulong len, DPos& e, bool reparse )
{
AutoLock lk( this );

Expand Down Expand Up @@ -535,7 +535,7 @@ bool DocImpl::InsertingOperation
}

// 再解析
return ReParse( s.tl, e.tl );
return reparse && ReParse( s.tl, e.tl );
}


Expand Down Expand Up @@ -731,20 +731,16 @@ void DocImpl::OpenFile( aptr<TextFileR> tf )
buf_sz = SBUF_SZ;
}

for( ulong i=0; tf->state(); )
size_t L;
ulong i=0;
for( i=0; L = tf->ReadBuf( buf, buf_sz ); )
{
if( size_t L = tf->ReadBuf( buf, buf_sz ) )
{
DPos p(i,0xffffffff);
InsertingOperation( p, buf, (ulong)L, e );
i = tln() - 1;
}
if( tf->state() == 1 )
{
DPos p(i++,0xffffffff);
InsertingOperation( p, L"\n", 1, e );
}
DPos p( i, len(e.tl) ); // end of document
InsertingOperation( p, buf, (ulong)L, e, /*reparse=*/false );
i = tln() - 1;
}
// Parse All lines, because we skipped it
ReParse( 0, tln()-1 );

if( buf != sbuf )
delete [] buf;
Expand Down

0 comments on commit 246df33

Please sign in to comment.