loolwsd: combine single rows only
Combining as much as possible is too aggressive and seems to harm performance where large areas are invalidated during editing (f.e. inserting text at the begining of a paragraph). With this patch we only combine a single row at a time. This is reasonable since rows almost always are invalidated when a line is edited. Larger blocks are typically less important. This is experimental and might get reverted if proves to harm more than help. Change-Id: I6e4420e07a031805c1e2729b3f32de580ae4806e Reviewed-on: https://gerrit.libreoffice.org/29289 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
5daf4ab341
commit
5905c3b3f2
2 changed files with 35 additions and 31 deletions
|
@ -201,43 +201,32 @@ MessageQueue::Payload TileQueue::get_impl()
|
|||
tiles.emplace_back(TileDesc::parse(msg));
|
||||
|
||||
// Combine as many tiles as possible with the top one.
|
||||
bool added;
|
||||
do
|
||||
for (size_t i = 0; i < _queue.size(); )
|
||||
{
|
||||
added = false;
|
||||
for (size_t i = 0; i < _queue.size(); )
|
||||
auto& it = _queue[i];
|
||||
msg = std::string(it.data(), it.size());
|
||||
if (msg.compare(0, 5, "tile ") != 0 ||
|
||||
msg.find("id=") != std::string::npos)
|
||||
{
|
||||
auto& it = _queue[i];
|
||||
msg = std::string(it.data(), it.size());
|
||||
if (msg.compare(0, 5, "tile ") != 0 ||
|
||||
msg.find("id=") != std::string::npos)
|
||||
{
|
||||
// Don't combine non-tiles or tiles with id.
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
// Don't combine non-tiles or tiles with id.
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto tile2 = TileDesc::parse(msg);
|
||||
Log::trace() << "combining candidate: " << msg << Log::end;
|
||||
auto tile2 = TileDesc::parse(msg);
|
||||
Log::trace() << "combining candidate: " << msg << Log::end;
|
||||
|
||||
// Check if adjacent tiles.
|
||||
bool found = false;
|
||||
for (auto& tile : tiles)
|
||||
{
|
||||
if (tile.isAdjacent(tile2))
|
||||
{
|
||||
tiles.emplace_back(tile2);
|
||||
_queue.erase(_queue.begin() + i);
|
||||
found = true;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i += !found;
|
||||
// Check if it's on the same row.
|
||||
if (tiles[0].onSameRow(tile2))
|
||||
{
|
||||
tiles.emplace_back(tile2);
|
||||
_queue.erase(_queue.begin() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
while (added);
|
||||
|
||||
Log::trace() << "Combined " << tiles.size() << " tiles, leaving " << _queue.size() << " in queue." << Log::end;
|
||||
|
||||
|
|
|
@ -90,6 +90,21 @@ public:
|
|||
return intersects(other);
|
||||
}
|
||||
|
||||
bool onSameRow(const TileDesc& other) const
|
||||
{
|
||||
if (other.getPart() != getPart() ||
|
||||
other.getWidth() != getWidth() ||
|
||||
other.getHeight() != getHeight() ||
|
||||
other.getTileWidth() != getTileWidth() ||
|
||||
other.getTileHeight() != getTileHeight())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return other.getTilePosY() + other.getTileHeight() >= getTilePosY() &&
|
||||
other.getTilePosY() <= getTilePosY() + getTileHeight();
|
||||
}
|
||||
|
||||
/// Serialize this instance into a string.
|
||||
/// Optionally prepend a prefix.
|
||||
std::string serialize(const std::string& prefix = "") const
|
||||
|
|
Loading…
Reference in a new issue