mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 10:11:21 +00:00
better table speedup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@2148 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3883c95207
commit
430ce1cc52
@ -1,3 +1,12 @@
|
||||
2001-06-27 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/insets/insettabular.C (getMaxWidth): do the speedup in a
|
||||
different way, remove dead code
|
||||
|
||||
* src/tabular.C (GetCellInset): store the last cell checked (gotten)
|
||||
|
||||
* src/tabular.h: new member cur_cell, used to cache cell values.
|
||||
|
||||
2001-06-24 The LyX Project <jug@sad.it>
|
||||
|
||||
* src/lyxlex_pimpl.C (compare_tags): use compare_ascii_no_case instead
|
||||
|
@ -1857,28 +1857,26 @@ int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
|
||||
int InsetTabular::getMaxWidth(Painter & pain,
|
||||
UpdatableInset const * inset) const
|
||||
{
|
||||
typedef std::map<UpdatableInset const *, int> Cache;
|
||||
static Cache cache;
|
||||
|
||||
int cell = -1;
|
||||
Cache::const_iterator ci = cache.find(inset);
|
||||
if (ci != cache.end()) {
|
||||
cell = (*ci).second;
|
||||
if (tabular->GetCellInset(cell) != inset) {
|
||||
cell = -1;
|
||||
}
|
||||
int cell = tabular->cur_cell;
|
||||
if (tabular->GetCellInset(cell) != inset) {
|
||||
cell = actcell;
|
||||
if (tabular->GetCellInset(cell) != inset) {
|
||||
lyxerr << "Actcell not equal to actual cell!" << std::endl;
|
||||
cell = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int const n = tabular->GetNumberOfCells();
|
||||
|
||||
if (cell == -1) {
|
||||
cell = 0;
|
||||
for (; cell < n; ++cell) {
|
||||
if (tabular->GetCellInset(cell) == inset)
|
||||
break;
|
||||
}
|
||||
cache[inset] = cell;
|
||||
cell = 0;
|
||||
for (; cell < n; ++cell) {
|
||||
if (tabular->GetCellInset(cell) == inset)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (cell >= n)
|
||||
return -1;
|
||||
int w = GetMaxWidthOfCell(pain, cell);
|
||||
|
@ -88,6 +88,7 @@ LyXTabular::columnstruct::columnstruct()
|
||||
LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
|
||||
{
|
||||
owner_ = inset;
|
||||
cur_cell = -1;
|
||||
Init(rows_arg, columns_arg);
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
|
||||
LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
|
||||
{
|
||||
owner_ = inset;
|
||||
cur_cell = -1;
|
||||
Init(lt.rows_, lt.columns_);
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
|
||||
@ -106,6 +108,7 @@ LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
|
||||
LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
|
||||
{
|
||||
owner_ = inset;
|
||||
cur_cell = -1;
|
||||
Read(buf, lex);
|
||||
}
|
||||
|
||||
@ -116,6 +119,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
|
||||
// So then it is ok to throw an exception, or for now
|
||||
// call abort()
|
||||
Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
|
||||
cur_cell = -1;
|
||||
|
||||
cell_info = lt.cell_info;
|
||||
row_info = lt.row_info;
|
||||
@ -3005,6 +3009,7 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const
|
||||
|
||||
InsetText * LyXTabular::GetCellInset(int cell) const
|
||||
{
|
||||
cur_cell = cell;
|
||||
return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
|
||||
}
|
||||
|
||||
|
@ -374,6 +374,8 @@ public:
|
||||
InsetTabular * owner() const { return owner_; }
|
||||
///
|
||||
void Validate(LaTeXFeatures &) const;
|
||||
///
|
||||
mutable int cur_cell;
|
||||
|
||||
private: //////////////////////////////////////////////////////////////////
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user