From c6b082a6263bbfcfab0dcc4f4c4bb2c024c84f10 Mon Sep 17 00:00:00 2001 From: Wang Guoliang Date: Fri, 24 Nov 2017 22:43:25 +0800 Subject: Replace strings.Index with strings.Contains --- fpdf.go | 10 +++++----- template.go | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/fpdf.go b/fpdf.go index a590581..1503a4e 100644 --- a/fpdf.go +++ b/fpdf.go @@ -1931,19 +1931,19 @@ func (f *Fpdf) CellFormat(w, h float64, txtStr string, borderStr string, ln int, if len(txtStr) > 0 { var dx, dy float64 // Horizontal alignment - if strings.Index(alignStr, "R") != -1 { + if strings.Contains(alignStr, "R") { dx = w - f.cMargin - f.GetStringWidth(txtStr) - } else if strings.Index(alignStr, "C") != -1 { + } else if strings.Contains(alignStr, "C") { dx = (w - f.GetStringWidth(txtStr)) / 2 } else { dx = f.cMargin } // Vertical alignment - if strings.Index(alignStr, "T") != -1 { + if strings.Contains(alignStr, "T") { dy = (f.fontSize - h) / 2.0 - } else if strings.Index(alignStr, "B") != -1 { + } else if strings.Contains(alignStr, "B") { dy = (h - f.fontSize) / 2.0 - } else if strings.Index(alignStr, "A") != -1 { + } else if strings.Contains(alignStr, "A") { var descent float64 d := f.currentFont.Desc if d.Descent == 0 { diff --git a/template.go b/template.go index 1826fd7..60b076b 100644 --- a/template.go +++ b/template.go @@ -254,9 +254,7 @@ func templateChainDependencies(template Template) []Template { requires := template.Templates() chain := make([]Template, len(requires)*2) for _, req := range requires { - for _, sub := range templateChainDependencies(req) { - chain = append(chain, sub) - } + chain = append(chain, templateChainDependencies(req)...) } chain = append(chain, template) return chain -- cgit v1.2.1-24-ge1ad