0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 06:23:52 +01:00

Don't encode object as UTF-8 string if not needed.

I believe that string formatting ~10-15 sized events will
take a proportion of CPU time.
This commit is contained in:
Michael Kaye 2019-10-24 18:08:45 +01:00
parent e39bc62b8a
commit f85b9842f0

View file

@ -125,9 +125,11 @@ def compute_event_signature(event_dict, signature_name, signing_key):
redact_json = prune_event_dict(event_dict) redact_json = prune_event_dict(event_dict)
redact_json.pop("age_ts", None) redact_json.pop("age_ts", None)
redact_json.pop("unsigned", None) redact_json.pop("unsigned", None)
logger.debug("Signing event: %s", encode_canonical_json(redact_json)) if logger.isEnabledFor(logging.DEBUG):
logger.debug("Signing event: %s", encode_canonical_json(redact_json))
redact_json = sign_json(redact_json, signature_name, signing_key) redact_json = sign_json(redact_json, signature_name, signing_key)
logger.debug("Signed event: %s", encode_canonical_json(redact_json)) if logger.isEnabledFor(logging.DEBUG):
logger.debug("Signed event: %s", encode_canonical_json(redact_json))
return redact_json["signatures"] return redact_json["signatures"]