Component
pygls/workspace/workspace.py
Summary
update_text_document calls unquote(doc_uri) and self._text_documents[...] twice in succession on every text change, which can be very frequent during normal editing.
Steps to Reproduce
- Type a single character in a document.
didChange triggers two identical unquote and dictionary lookups.
Expected Behavior
Single lookup and unquote per edit.
Actual Behavior
Redundant operations on the hot path.
Affected Code (pygls/workspace/workspace.py, ~L280-282)
self._text_documents[unquote(doc_uri)].apply_change(change)
self._text_documents[unquote(doc_uri)].version = text_doc.version
Proposed Fix
doc = self._text_documents[unquote(doc_uri)]
doc.apply_change(change)
doc.version = text_doc.version
Component
pygls/workspace/workspace.py
Summary
update_text_documentcallsunquote(doc_uri)andself._text_documents[...]twice in succession on every text change, which can be very frequent during normal editing.Steps to Reproduce
didChangetriggers two identicalunquoteand dictionary lookups.Expected Behavior
Single lookup and unquote per edit.
Actual Behavior
Redundant operations on the hot path.
Affected Code (
pygls/workspace/workspace.py, ~L280-282)Proposed Fix