Skip to content

Commit

Permalink
bluesky.to_as1: noop, tiny optimization, don't UTF8-encode hashtag te…
Browse files Browse the repository at this point in the history
…xt twice
  • Loading branch information
snarfed committed May 31, 2024
1 parent 2d6c32a commit 8b54c6d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions granary/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,10 @@ def to_as1(obj, type=None, uri=None, repo_did=None, repo_handle=None,

try:
if byte_start is not None:
tag['startIndex'] = len(text.encode()[:byte_start].decode())
text_encoded = text.encode()
tag['startIndex'] = len(text_encoded[:byte_start].decode())
if byte_end is not None:
name = text.encode()[byte_start:byte_end].decode()
name = text_encoded[byte_start:byte_end].decode()
tag.setdefault('displayName', name)
tag['length'] = len(name)
except UnicodeDecodeError as e:
Expand Down

0 comments on commit 8b54c6d

Please sign in to comment.