Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-22
17:19 • Ticket [2544740fff] interp create O(N^2) search for unused cmd name status... artifact: 5700114488 user: serhiy.storchaka
2026-10-21
10:03 • Closed ticket [2544740fff]. artifact: 5d12524275 user: serhiy.storchaka
2009-01-29
05:49 • New ticket [2544740fff]. artifact: 14ec987daa user: dgp

[interp create] O(N^2) search for unused cmd name

Closed / Fixed2544740fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 41 days ago
Descriptionplain2009-01-29 05:49:04
When not given a slave cmd name,
[interp create] invents one
of the form "interp%d".

The search for an unused cmd name
always starts with %d == 0 and
increments by one, so a loop
of [interp create] statements will
exhibit N^2 performance to do an
inherently linear task.

Simply storing the last used %d
value is enough to solve it.
serhiy.storchakawiki2026-10-21 10:03:36

Fixed in 9.0.0 by [7a665fa1b6]: a per-parent counter replaces the search from interp0. 8.6 keeps the old loop.

serhiy.storchaka Ticket [2544740fff]: 3 changes [History diff]2026-10-22 17:19:30
Log in (anonymous is fine) to add a comment.