Overview
| Artifact ID: | e6c433289d93615e02f35a384f33b70bc207c47c |
|---|---|
| Ticket: | 1890831fffffffffffffffffffffffffffffffff
Lrange cleanup and in-place optimization |
| User & Date: | ferrieux on 2008-02-10 23:30:16 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
The attached patch against 8.5.1 is a cleanup of the [lrange] implementation, including: - use of T_LOL to stick to the style of other list ops, instead of a complex and unique anti-shimmering share-intrep mechanism dedicated to a rare and already fast case [lrange $x $x $x]. - flattening of if-return's to stick to the style of other list ops, improving readability. - detection of unshared case to operate in-place, by calling twice Tcl_ListObjReplace (in correct order). The first two points are just a matter of style, but allow for the third, which is a pretty significant optimization. Measurements on a 100-million list [lrepeat 100000000 1]: [lrange ... 1 end] in-place gives a 3x speedup [lrange ... 0 end-1] in-place gives a 24000x speedup -Alex % set l [lrepeat 100000000 1];llength $l 100000000 % time {set l [lrange $l 1 end];llength $l} 814663 microseconds per iteration % proc K { x y } {set x} % time {set l [lrange [K $l [unset l]] 1 end];llength $l} 272517 microseconds per iteration % set l [lrepeat 100000000 1];llength $l 100000000 % time {set l [lrange $l 0 end-1];llength $l} 815985 microseconds per iteration % set l [lrepeat 100000000 1];llength $l 100000000 % time {set l [lrange [K $l [unset l]] 0 end-1];llength $l} 34 microseconds per iteration - foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ferrieux"
- subsystem changed to: "17. Commands I-L"
- title changed to: "Lrange cleanup and in-place optimization"
- type changed to: "Patch"