aboutsummaryrefslogtreecommitdiff
path: root/src/regexp
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2017-10-28 17:35:27 +0100
committerDaniel Martí <mvdan@mvdan.cc>2017-10-31 20:07:46 +0000
commit7cb3e4fb1d6b2704ecdc3d6983587975ce077a34 (patch)
treede4fe981bb9df8912617c91e068125f66479ae23 /src/regexp
parent94484d8ed5155873306ab41f49b0b30be19031a9 (diff)
downloadgo-7cb3e4fb1d6b2704ecdc3d6983587975ce077a34.tar.gz
go-7cb3e4fb1d6b2704ecdc3d6983587975ce077a34.zip
all: unindent some if bodies by exiting early
All of these had a return or break in the else body, so flipping the condition means we can unindent and simplify. Change-Id: If93e97504480d18a0dac3f2c8ffe57ab8bcb929c Reviewed-on: https://go-review.googlesource.com/74190 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/regexp')
-rw-r--r--src/regexp/exec.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/regexp/exec.go b/src/regexp/exec.go
index ea5b1361cb..84cb3e6fa5 100644
--- a/src/regexp/exec.go
+++ b/src/regexp/exec.go
@@ -338,15 +338,14 @@ func (m *machine) onepass(i input, pos, ncap int) bool {
if pos == 0 && syntax.EmptyOp(inst.Arg)&^flag == 0 &&
len(m.re.prefix) > 0 && i.canCheckPrefix() {
// Match requires literal prefix; fast search for it.
- if i.hasPrefix(m.re) {
- pos += len(m.re.prefix)
- r, width = i.step(pos)
- r1, width1 = i.step(pos + width)
- flag = i.context(pos)
- pc = int(m.re.prefixEnd)
- } else {
+ if !i.hasPrefix(m.re) {
return m.matched
}
+ pos += len(m.re.prefix)
+ r, width = i.step(pos)
+ r1, width1 = i.step(pos + width)
+ flag = i.context(pos)
+ pc = int(m.re.prefixEnd)
}
for {
inst = m.op.Inst[pc]