diff options
| author | Olivier Dony <odo@openerp.com> | 2015-03-26 19:28:57 +0100 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2015-03-27 14:44:56 +0100 |
| commit | d555fdac0c089a3d99497376e818f58c7e38d59c (patch) | |
| tree | ebcb739da992dd1cd587d8a312d3cbf40f3f2c97 /addons/analytic_user_function/security | |
| parent | cd08281979c0d50a0f135ed452d2a15c6bcc3324 (diff) | |
[IMP] tools.ustr: speed up average call by short-circuiting common cases
Direct type comparison is significantly faster than
isinstance/issubclass calls, so it is worth using
in a method that is very frequently called.
The extra call to getencoding() also causes a significant
overhead, so we try to spare it by tring the hint_encoding
first. If all fails, the default behavior still applies.
Using micro-benchmarks, the execution time of
ustr() on an already-unicode string is cut in
half (no conversion is needed), and the overhead
for converting utf-8 bytestrings is also
cut in half (the conversion itself is O(n) on
the string length, obviously)
Diffstat (limited to 'addons/analytic_user_function/security')
0 files changed, 0 insertions, 0 deletions
