From 09807e7391b9a292d2386c37fa60880ff0f12e49 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@nokia.com> Date: Mon, 8 Mar 2010 20:20:28 +0100 Subject: [PATCH] Reserving needed amount of memory before copying. --- src/plugins/bineditor/bineditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index ec33a8889e9..656d80b1d3c 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -230,6 +230,7 @@ QByteArray BinEditor::dataMid(int from, int length) const int block = from / m_blockSize; QByteArray data; + data.reserve(length); do { data += blockData(block++); } while (block * m_blockSize < end); @@ -1138,6 +1139,7 @@ void BinEditor::copy(bool raw) } QString hexString; const char * const hex = "0123456789abcdef"; + hexString.reserve(3 * data.size()); for (int i = 0; i < data.size(); ++i) { const uchar val = static_cast<uchar>(data[i]); hexString.append(hex[val >> 4]).append(hex[val & 0xf]).append(' '); -- GitLab