Homec4science

Improve performance of phutil_utf8_shorten()

Authored by epriestley <git@epriestley.com> on Jun 12 2013, 04:51.

Description

Improve performance of phutil_utf8_shorten()

Summary:
This function is a little slower and more complex than necessary:

  • If the string to shorten has fewer bytes than the maximum length, it certainly has fewer characters, and we can skip all the expensive utf8 operations.
  • If the terminal is longer than the maximum length, just return it unmodified. Throwing is messy and excessively strict, and we need to do expensive utf8 operations early in the function to ensure we throw consistently.

Test Plan: This is well-covered by unit tests.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6182

Details

Committed
epriestley <git@epriestley.com>Jun 12 2013, 04:51
Pushed
aubortMar 17 2017, 12:03
Parents
rPHUf57b8334b7ed: Improve invalid workflow message.
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHU8161f709c4f0: Improve performance of phutil_utf8_shorten() (authored by epriestley <git@epriestley.com>).Jun 12 2013, 04:51