mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
* src/changes.C:
* src/changes.h: some speed optimizations as the result of profiling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16584 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
892cad985c
commit
94cbc4468e
@ -77,18 +77,6 @@ bool operator!=(Changes::Range const & r1, Changes::Range const & r2)
|
||||
}
|
||||
|
||||
|
||||
bool Changes::Range::contains(Range const & r) const
|
||||
{
|
||||
return r.start >= start && r.end <= end;
|
||||
}
|
||||
|
||||
|
||||
bool Changes::Range::contains(pos_type const pos) const
|
||||
{
|
||||
return pos >= start && pos < end;
|
||||
}
|
||||
|
||||
|
||||
bool Changes::Range::intersects(Range const & r) const
|
||||
{
|
||||
return r.start < end && r.end > start; // end itself is not in the range!
|
||||
@ -230,8 +218,10 @@ void Changes::insert(Change const & change, lyx::pos_type pos)
|
||||
}
|
||||
|
||||
|
||||
Change const Changes::lookup(pos_type const pos) const
|
||||
Change const & Changes::lookup(pos_type const pos) const
|
||||
{
|
||||
static Change const noChange = Change(Change::UNCHANGED);
|
||||
|
||||
ChangeTable::const_iterator it = table_.begin();
|
||||
ChangeTable::const_iterator const end = table_.end();
|
||||
|
||||
@ -240,7 +230,7 @@ Change const Changes::lookup(pos_type const pos) const
|
||||
return it->change;
|
||||
}
|
||||
|
||||
return Change(Change::UNCHANGED);
|
||||
return noChange;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
///
|
||||
|
||||
/// return the change at the given pos
|
||||
Change const lookup(pos_type pos) const;
|
||||
Change const & lookup(pos_type pos) const;
|
||||
|
||||
/// return true if there is a change in the given range (excluding end)
|
||||
bool isChanged(pos_type start, pos_type end) const;
|
||||
@ -89,11 +89,15 @@ private:
|
||||
Range(pos_type s, pos_type e)
|
||||
: start(s), end(e) {}
|
||||
|
||||
// does this range contain r ?
|
||||
bool contains(Range const & r) const;
|
||||
// does this range contain r ? (inlined as the result of profiling)
|
||||
bool contains(Range const & r) const {
|
||||
return r.start >= start && r.end <= end;
|
||||
}
|
||||
|
||||
// does this range contain pos ?
|
||||
bool contains(pos_type pos) const;
|
||||
// does this range contain pos ? (inlined as the result of profiling)
|
||||
bool contains(pos_type pos) const {
|
||||
return pos >= start && pos < end;
|
||||
}
|
||||
|
||||
// do the ranges intersect ?
|
||||
bool intersects(Range const & r) const;
|
||||
|
Loading…
Reference in New Issue
Block a user