ooxml

Check-in [2b3d6087ca]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use a fast temporary lookup array for all elements of sharedStrings, to avoid repeated lsearch on a potential every growing list. Inside the loop: since new elements are always appended on the list, the pos of the new list is just the llength - 1. For my tests, this changes already speeds the writing up of almost 3 times.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | speed
Files: files | file ages | folders
SHA3-256: 2b3d6087ca3bdd68ad579d37593a50b1292a4e18801ac345fb66c3dab0f3e982
User & Date: rolf 2019-08-08 18:51:59
Context
2019-08-08
19:03
Saving the [expr ...] is probably even a tiny little better. check-in: 47cf52d42b user: rolf tags: speed
18:51
Use a fast temporary lookup array for all elements of sharedStrings, to avoid repeated lsearch on a potential every growing list. Inside the loop: since new elements are always appended on the list, the pos of the new list is just the llength - 1. For my tests, this changes already speeds the writing up of almost 3 times. check-in: 2b3d6087ca user: rolf tags: speed
13:32
merged idomidioms check-in: 07a138a2f1 user: alex tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

2225
2226
2227
2228
2229
2230
2231
2232



2233
2234


2235
2236
2237
2238
2239
2240

2241
2242
2243
2244
2245
2246
2247
2248

    if {[::ooxml::Getopt opts {holdcontainerdirectory} $args]} {
      error $opts(-errmsg)
    }

    foreach {n v} [array get cells] {
      if {[dict exists $v t] && [dict get $v t] eq {s} && [dict exists $v v] && [dict get $v v] ne {}} {
	if {[set pos [lsearch -exact $sharedStrings [dict get $v v]]] == -1} {



	  lappend sharedStrings [dict get $v v]
	  set pos [lsearch -exact $sharedStrings [dict get $v v]]


	}
	set obj(sharedStrings) 1
	dict set cells($n) v $pos
      }
    }
    unset -nocomplain n v


    # _rels/.rels
    set doc [set obj(doc,_rels/.rels) [dom createDocument Relationships]]
    set root [$doc documentElement]

    set rId 0

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship







|
>
>
>
|
<
>
>

|




>
|







2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236

2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253

    if {[::ooxml::Getopt opts {holdcontainerdirectory} $args]} {
      error $opts(-errmsg)
    }

    foreach {n v} [array get cells] {
      if {[dict exists $v t] && [dict get $v t] eq {s} && [dict exists $v v] && [dict get $v v] ne {}} {
        set thisv [dict get $v v]
        if {[info exists lookup($thisv)]} {
          set pos $lookup($thisv)
        } else {
	  lappend sharedStrings $thisv

	  set pos [expr {[llength $sharedStrings] - 1}]
          set lookup($thisv) $pos
	}
        set obj(sharedStrings) 1
	dict set cells($n) v $pos
      }
    }
    unset -nocomplain n v
    array unset lookup
    
    # _rels/.rels
    set doc [set obj(doc,_rels/.rels) [dom createDocument Relationships]]
    set root [$doc documentElement]

    set rId 0

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship