diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-23 08:08:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-23 08:08:08 (GMT) |
commit | 42bcf37fcffa65592e401c43aa8c0190452b28b0 (patch) | |
tree | 8daf6bd5c396224c5f7000fa5937ff6d8f7e9b06 /Modules/_tracemalloc.c | |
parent | d65e0c7560f8a5ad31d31892cee6f1416293ca39 (diff) | |
download | cpython-42bcf37fcffa65592e401c43aa8c0190452b28b0.zip cpython-42bcf37fcffa65592e401c43aa8c0190452b28b0.tar.gz cpython-42bcf37fcffa65592e401c43aa8c0190452b28b0.tar.bz2 |
Issue #26588: Optimize tracemalloc_realloc()
No need to remove the old trace if the memory block didn't move.
Diffstat (limited to 'Modules/_tracemalloc.c')
-rw-r--r-- | Modules/_tracemalloc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index 3d96860..139b169 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -633,7 +633,12 @@ tracemalloc_realloc(void *ctx, void *ptr, size_t new_size) /* an existing memory block has been resized */ TABLES_LOCK(); - REMOVE_TRACE(ptr); + + /* tracemalloc_add_trace() updates the trace if there is already + a trace at address (domain, ptr2) */ + if (ptr2 != ptr) { + REMOVE_TRACE(ptr); + } if (ADD_TRACE(ptr2, new_size) < 0) { /* Memory allocation failed. The error cannot be reported to |