feat: #SAM-904 remove grapheme nil check

- it will panic on g.Reset, if nil
This commit is contained in:
Dilshan Sandhu
2024-04-27 01:59:18 +05:30
parent 9c3bfbf40c
commit d3a37e96a9

View File

@ -236,10 +236,6 @@ func toTree(drafty *document) (*node, error) {
// Given a grapheme iterator, start and end pos, returns a new grapheme iterator
// containing a slice of graphemes(start->end) from input interator.
func sliceGraphemeClusters(g *uniseg.Graphemes, start, end int) *uniseg.Graphemes {
if g == nil {
return uniseg.NewGraphemes("")
}
g.Reset()
output := ""
@ -270,9 +266,6 @@ func sliceGraphemeClusters(g *uniseg.Graphemes, start, end int) *uniseg.Grapheme
// Given a grapheme iterator, returns the original string from which it was created from.
func graphemeToString(g *uniseg.Graphemes) string {
if g == nil {
return ""
}
g.Reset()
output := ""
@ -286,9 +279,6 @@ func graphemeToString(g *uniseg.Graphemes) string {
// Returns the number of grapheme cluster found in iterator.
func getGraphemeLength(g *uniseg.Graphemes) int {
if g == nil {
return 0
}
g.Reset()
output := 0