Skip to content

Commit

Permalink
remove unused (*compiler).size*()
Browse files Browse the repository at this point in the history
  • Loading branch information
yosida95 committed Aug 31, 2020
1 parent 56a67b7 commit b08c3d0
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func (c *compiler) opWithName(opcode progOpcode, name string) uint32 {
return addr
}

func (c *compiler) sizeString(str string) uint32 {
return uint32(utf8.RuneCountInString(str))
}

func (c *compiler) compileString(str string) {
for i := 0; i < len(str); {
// NOTE(yosida95): It is confirmed at parse time that literals
Expand All @@ -67,10 +63,6 @@ func (c *compiler) compileString(str string) {
}
}

func (c *compiler) sizeRuneClass(rc runeClass, maxlen int) uint32 {
return 7*uint32(maxlen) - 1
}

func (c *compiler) compileRuneClass(rc runeClass, maxlen int) {
for i := 0; i < maxlen; i++ {
if i > 0 {
Expand All @@ -85,10 +77,6 @@ func (c *compiler) compileRuneClass(rc runeClass, maxlen int) {
}
}

func (c *compiler) sizeRuneClassInfinite(rc runeClass) uint32 {
return 8
}

func (c *compiler) compileRuneClassInfinite(rc runeClass) {
start := c.opWithAddrDelta(opSplit, 3) // raw rune or pct-encoded
c.opWithRuneClass(opRuneClass, rc) // raw rune
Expand All @@ -100,16 +88,6 @@ func (c *compiler) compileRuneClassInfinite(rc runeClass) {
c.opWithAddr(opJmp, start) //
}

func (c *compiler) sizeVarspecValue(spec varspec, expr *expression) uint32 {
size := uint32(2) // opCapStart + opCapEnd
if spec.maxlen > 0 {
size += c.sizeRuneClass(expr.allow, spec.maxlen)
} else {
size += c.sizeRuneClassInfinite(expr.allow)
}
return size
}

func (c *compiler) compileVarspecValue(spec varspec, expr *expression) {
var specname string
if spec.maxlen > 0 {
Expand All @@ -133,22 +111,6 @@ func (c *compiler) compileVarspecValue(spec varspec, expr *expression) {
c.prog.op[split].i = capEnd
}

func (c *compiler) sizeVarspec(spec varspec, expr *expression) uint32 {
var sep string
if spec.explode {
sep = expr.sep
} else {
sep = ","
}

size := 5 + c.sizeString(expr.ifemp) + c.sizeVarspecValue(spec, expr) + c.sizeString(sep)
if expr.named {
size += c.sizeString(spec.name) + 1
size += c.sizeString("=")
}
return size
}

func (c *compiler) compileVarspec(spec varspec, expr *expression) {
switch {
case expr.named && spec.explode:
Expand Down

0 comments on commit b08c3d0

Please sign in to comment.