summary refs log tree commit diff
path: root/synapse/events/__init__.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-23 14:58:08 +0000
committerErik Johnston <erik@matrix.org>2016-03-23 14:58:08 +0000
commitfe9794706ab817fcedc17f99693eb0823b339d93 (patch)
treebdb1a2f64b8397f2992287509e480cc09c01a8ca /synapse/events/__init__.py
parentString intern (diff)
downloadsynapse-fe9794706ab817fcedc17f99693eb0823b339d93.tar.xz
Intern type and state_key on events
Diffstat (limited to 'synapse/events/__init__.py')
-rw-r--r--synapse/events/__init__.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index abed6b5e6b..2ceac19adb 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 from synapse.util.frozenutils import freeze
+from synapse.util.caches import intern_string
 
 
 # Whether we should use frozen_dict in FrozenEvent. Using frozen_dicts prevents
@@ -140,6 +141,12 @@ class FrozenEvent(EventBase):
 
         unsigned = dict(event_dict.pop("unsigned", {}))
 
+        # We intern these strings because they turn up a lot (especially when
+        # caching).
+        event_dict["type"] = intern_string(event_dict["type"])
+        if "state_key" in event_dict:
+            event_dict["state_key"] = intern_string(event_dict["state_key"])
+
         if USE_FROZEN_DICTS:
             frozen_dict = freeze(event_dict)
         else: