mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Avoid inefficient behavior
Since the class needs to be copy-constructible, there may be many copies of an instance. So instead of writing to the device on every destructor call, only flush buffer on the last destructor call.
This commit is contained in:
parent
4142722303
commit
7b0b5e3d7f
1 changed files with 5 additions and 3 deletions
|
@ -41,9 +41,11 @@ Utils::IO::FileDeviceOutputIterator::FileDeviceOutputIterator(QFileDevice &devic
|
|||
|
||||
Utils::IO::FileDeviceOutputIterator::~FileDeviceOutputIterator()
|
||||
{
|
||||
if (m_device->error() == QFileDevice::NoError)
|
||||
m_device->write(*m_buffer);
|
||||
m_buffer->clear();
|
||||
if (m_buffer.use_count() == 1) {
|
||||
if (m_device->error() == QFileDevice::NoError)
|
||||
m_device->write(*m_buffer);
|
||||
m_buffer->clear();
|
||||
}
|
||||
}
|
||||
|
||||
Utils::IO::FileDeviceOutputIterator &Utils::IO::FileDeviceOutputIterator::operator=(const char c)
|
||||
|
|
Loading…
Reference in a new issue