Use ElementStyle as a value instead of pointer, so we can drop all the annoying nil checks

This commit is contained in:
Christian Muehlhaeuser
2019-12-05 18:05:29 +01:00
parent 556c490ac4
commit 78e36a02d0
11 changed files with 147 additions and 176 deletions
+4 -4
View File
@@ -6,7 +6,7 @@ import (
type BlockElement struct {
Block *bytes.Buffer
Style *ElementStyle
Style ElementStyle
}
type BlockStack []BlockElement
@@ -29,7 +29,7 @@ func (s BlockStack) Indent() uint {
var i uint
for _, v := range s {
if v.Style == nil || v.Style.Indent == nil {
if v.Style.Indent == nil {
continue
}
i += *v.Style.Indent
@@ -42,7 +42,7 @@ func (s BlockStack) Margin() uint {
var i uint
for _, v := range s {
if v.Style == nil || v.Style.Margin == nil {
if v.Style.Margin == nil {
continue
}
i += *v.Style.Margin
@@ -69,6 +69,6 @@ func (s BlockStack) Current() BlockElement {
return s[len(s)-1]
}
func (s BlockStack) With(child *ElementStyle) *ElementStyle {
func (s BlockStack) With(child ElementStyle) ElementStyle {
return cascadeStyle(s.Current().Style, child, true)
}