summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@gmail.com>2015-10-11 13:23:37 -0400
committerKurt Jung <kurt.w.jung@gmail.com>2015-10-11 13:23:37 -0400
commit13a5fda5f79f2c15eea512e6ec3de2ce60aa29ca (patch)
treef513ff36d45b5961007725e3e135dec258a4b7f9 /fpdf.go
parent08c842eee7361c4d515301a5d84d246a0b0a9462 (diff)
Conditionally sort two map iterations in template code; more to come.
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/fpdf.go b/fpdf.go
index b5ed8e6..08bcb2e 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -3366,10 +3366,29 @@ func (f *Fpdf) putxobjectdict() {
f.outf("/I%d %d 0 R", image.i, image.n)
}
}
- for _, tpl := range f.templates {
- id := tpl.ID()
- if objID, ok := f.templateObjects[id]; ok {
- f.outf("/TPL%d %d 0 R", id, objID)
+ {
+ var key int64
+ var keyList []int64
+ var tpl Template
+ for key = range f.templates {
+ keyList = append(keyList, key)
+ }
+ if f.catalogSort {
+ gensort(len(keyList),
+ func(a, b int) bool {
+ return keyList[a] < keyList[b]
+ },
+ func(a, b int) {
+ keyList[a], keyList[b] = keyList[b], keyList[a]
+ })
+ }
+ for _, key = range keyList {
+ tpl = f.templates[key]
+ // for _, tpl := range f.templates {
+ id := tpl.ID()
+ if objID, ok := f.templateObjects[id]; ok {
+ f.outf("/TPL%d %d 0 R", id, objID)
+ }
}
}
}