Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f550fecb92a1ecd363fc8a58a0288b786b444b45
Ticket: 466037ffffffffffffffffffffffffffffffffff
Optimise getting the head/tail of a list
User & Date: kennykb on 2001-10-03 22:28:56
Changes

  1. assignee changed to: "kennykb"
  2. icomment:
    Logged In: YES 
    user_id=99768
    
    The changes I'm working on for TIP #22 already have a Tcl_ObjType for 'end-' indices.  Note that 
    Tcl_GetIntForIndex should be extremely fast if the index is constant because the first couple of lines of 
    code check for 'int' and 'index' objtypes, and the string rep is examined only if both those checks fail.
    
    We may at some point want to revisit what happens for [lindex $list end-$i], but that's farther out.
    
    For what it's worth, what's compiled for [lindex $list $i], with $list and $i both local, is
    
        INST_LOAD_SCALAR1 <var # for list>
        INST_LOAD_SCALAR1 <var # for i>
        INST_LIST_INDEX
    
    For [lindex $list 0], it'll be
    
        INST_LOAD_SCALAR1 <var # for list>
        INST_PUSH1 <literal # for 0>
        INST_LIST_LINDEX
    
    INST_LIST_LINDEX does indeed call TclGetIntForIndex, but that's been changed to begin with looking for 
    tclIntType and tclEndOffsetType and not do any parsing if the object is already a known type.
    
    Let's see how that does on the benchmarks before we try to squeeze any more out of it.
    
    
  3. login: "kennykb"
  4. mimetype: "text/plain"
  5. username: "kennykb"