forked from qt-creator/qt-creator
C++: change working-copy to work on UTF-8 encoded QByteArrays.
These not only take less space than UTF-16 encoded QStrings, but due to the caching in the CppEditorSupport also take less time to build. This patch also fixes a number of possible encoding issues, where files and constant strings were (falsely) assumed to be UTF-8. Change-Id: Ib6f91c9a94ebed5b5dfbd4eb2998825c62c72784 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -176,29 +176,38 @@ public:
|
||||
QByteArray m_defines;
|
||||
};
|
||||
|
||||
/// The working-copy stores all files that are stored on disk in their current state.
|
||||
///
|
||||
/// So, currently the working copy holds:
|
||||
/// - unsaved content of editors
|
||||
/// - uic-ed UI files (through \c AbstractEditorSupport)
|
||||
/// - the preprocessor configuration
|
||||
///
|
||||
/// Contents are keyed on filename, and hold the revision in the editor and the editor's
|
||||
/// contents encoded as UTF-8.
|
||||
class CPPTOOLS_EXPORT WorkingCopy
|
||||
{
|
||||
public:
|
||||
void insert(const QString &fileName, const QString &source, unsigned revision = 0)
|
||||
void insert(const QString &fileName, const QByteArray &source, unsigned revision = 0)
|
||||
{ _elements.insert(fileName, qMakePair(source, revision)); }
|
||||
|
||||
bool contains(const QString &fileName) const
|
||||
{ return _elements.contains(fileName); }
|
||||
|
||||
QString source(const QString &fileName) const
|
||||
QByteArray source(const QString &fileName) const
|
||||
{ return _elements.value(fileName).first; }
|
||||
|
||||
QPair<QString, unsigned> get(const QString &fileName) const
|
||||
QPair<QByteArray, unsigned> get(const QString &fileName) const
|
||||
{ return _elements.value(fileName); }
|
||||
|
||||
QHashIterator<QString, QPair<QString, unsigned> > iterator() const
|
||||
{ return QHashIterator<QString, QPair<QString, unsigned> >(_elements); }
|
||||
QHashIterator<QString, QPair<QByteArray, unsigned> > iterator() const
|
||||
{ return QHashIterator<QString, QPair<QByteArray, unsigned> >(_elements); }
|
||||
|
||||
int size() const
|
||||
{ return _elements.size(); }
|
||||
|
||||
private:
|
||||
typedef QHash<QString, QPair<QString, unsigned> > Table;
|
||||
typedef QHash<QString, QPair<QByteArray, unsigned> > Table;
|
||||
Table _elements;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user