Clean up and optimize parts of WebAPIResource.
Review Request #13278 — Created Sept. 19, 2023 and submitted — Latest diff uploaded
This reworks some of
WebAPIResourceto reduce unnecessary busywork and
reorganize some blocks of code to help with maintenance, performance,
Initial state setup for resources no longer allocates more memory for
allowed_mimetypeswhen there's no vendor required for resources
(though a vendor is recommended).
Dynamically-created state caches and key lookups are now accessed via a
try/exceptrather than a series of
incalls, which is
faster overall and especially in the common case. Some caches are now
built with reduced loops or overhead.
Object serialization now computes all request-specific code (cache
setup, expanded resources) up-front in one
if request:, in order to
make it clear what's state setup and what's payload building.
lookups, and list allocations have been removed.
Some string building has been replaced with f-strings.
Small optimizations that add up, saving a few seconds in my typical unit
test runs for Review Board's API test suite.
Djblets and Review Board test suites pass.