Tcl Source Code

View Ticket
Login
Ticket UUID: 2544740
Title: [interp create] O(N^2) search for unused cmd name
Type: Bug Created on: 2009-01-29 05:49:04
Submitter: dgp Assigned to: dgp
Subsystem: 20. [interp] Severity:
Priority: 5 Medium Last modified: 2026-10-22 17:19:30
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-21 10:03:36
Version: obsolete: 8.6b1.1
Description:
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.
User Comments:
serhiy.storchaka added on 2026-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.