diff --git a/src/plugins/coreplugin/id.cpp b/src/plugins/coreplugin/id.cpp
index 32b7d4ac8fec0978ab2fdd90626489c066b788ce..131920b9cc49562024fe0521e15628557c814a7d 100644
--- a/src/plugins/coreplugin/id.cpp
+++ b/src/plugins/coreplugin/id.cpp
@@ -34,7 +34,10 @@
 #include "coreconstants.h"
 #include "icontext.h"
 
+#include <utils/qtcassert.h>
+
 #include <QtCore/QHash>
+#include <QtCore/QDebug>
 
 namespace Core {
 
@@ -47,27 +50,40 @@ namespace Core {
 
 */
 
-uint qHash(const Core::Id &id) { return qHash(id.name()); }
+static int lastUid = 0;
+static QVector<QByteArray> stringFromId;
+static QHash<QByteArray, int> idFromString;
 
-static QHash<Core::Id, int> &theUniqueIdentifiers()
+static int theId(const QByteArray &ba)
 {
-    static QHash<Core::Id, int> data;
-    return data;
+    QTC_ASSERT(!ba.isEmpty(), /**/);
+    int res = idFromString.value(ba);
+    if (res == 0) {
+        if (lastUid == 0)
+            stringFromId.append(QByteArray());
+        res = ++lastUid;
+        idFromString[ba] = res;
+        stringFromId.append(ba);
+    }
+    return res;
 }
 
-int Id::uniqueIdentifier() const
-{
-    if (theUniqueIdentifiers().contains(*this))
-        return theUniqueIdentifiers().value(*this);
+Id::Id(const char *name)
+    : m_id(theId(name))
+{}
 
-    const int uid = theUniqueIdentifiers().count() + 1;
-    theUniqueIdentifiers().insert(*this, uid);
-    return uid;
+Id::Id(const QString &name)
+   : m_id(theId(name.toLatin1()))
+{}
+
+QByteArray Id::name() const
+{
+    return stringFromId.at(m_id);
 }
 
-Id Id::fromUniqueIdentifier(int uid)
+QString Id::toString() const
 {
-    return theUniqueIdentifiers().key(uid);
+    return QString::fromLatin1(stringFromId[m_id]);
 }
 
 Context::Context(const char *id, int offset)
diff --git a/src/plugins/coreplugin/id.h b/src/plugins/coreplugin/id.h
index 07e38df04a6ea2164e78ce9db7fa035d6b6c98dd..972166869507d00fe11498969a23172a8775b1e8 100644
--- a/src/plugins/coreplugin/id.h
+++ b/src/plugins/coreplugin/id.h
@@ -44,25 +44,26 @@ namespace Core {
 class CORE_EXPORT Id
 {
 public:
-    Id() {}
-    Id(const char *name) : m_name(name) {}
+    Id() : m_id(0) {}
+    Id(const char *name);
     // FIXME: Replace with QByteArray
-    Id(const QString &name) : m_name(name.toLatin1()) {}
-    QByteArray name() const { return m_name; }
-    QString toString() const { return QString::fromLatin1(m_name); }
-    bool isValid() const { return !m_name.isEmpty(); }
-    bool operator==(const Id &id) const { return m_name == id.m_name; }
-    bool operator!=(const Id &id) const { return m_name != id.m_name; }
-    int uniqueIdentifier() const;
-    static Id fromUniqueIdentifier(int uid);
+    Id(const QString &name);
+    QByteArray name() const;
+    QString toString() const;
+    bool isValid() const { return m_id; }
+    bool operator==(const Id &id) const { return m_id == id.m_id; }
+    bool operator!=(const Id &id) const { return m_id != id.m_id; }
+    int uniqueIdentifier() const { return m_id; }
+    static Id fromUniqueIdentifier(int uid) { return Id(uid, uid); }
 
 private:
+    Id(int uid, int) : m_id(uid) {}
     // Intentionally unimplemented
     Id(const QLatin1String &);
-    QByteArray m_name;
+    int m_id;
 };
 
-CORE_EXPORT uint qHash(const Id &id);
+CORE_EXPORT inline uint qHash(const Id &id) { return id.uniqueIdentifier(); }
 
 } // namespace Core