aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/fix/stringssplit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-02-21 12:19:54 -0500
committerRuss Cox <rsc@golang.org>2013-02-21 12:19:54 -0500
commitdf93283d5694814efc97efd2132da11722d11523 (patch)
tree53ffc57362ce1141a12ada5562bb86d2030ce469 /src/cmd/fix/stringssplit.go
parent92cbf82f1443223e21856f408b50821082babecc (diff)
downloadgo-df93283d5694814efc97efd2132da11722d11523.tar.xz
cmd/fix: delete pre-Go 1 fixes
Assume people who were going to update to Go 1 have done so. Those with pre-Go 1 trees remaining will need to update first to Go 1.0 (using its 'go fix') and then to Go 1.1. Cuts the cmd/fix test time by 99% (3 seconds to 0.03 seconds). R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7402046
Diffstat (limited to 'src/cmd/fix/stringssplit.go')
-rw-r--r--src/cmd/fix/stringssplit.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/cmd/fix/stringssplit.go b/src/cmd/fix/stringssplit.go
deleted file mode 100644
index d89ecf039c..0000000000
--- a/src/cmd/fix/stringssplit.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "go/ast"
- "go/token"
-)
-
-func init() {
- register(stringssplitFix)
-}
-
-var stringssplitFix = fix{
- "stringssplit",
- "2011-06-28",
- stringssplit,
- `Restore strings.Split to its original meaning and add strings.SplitN. Bytes too.
-
-http://codereview.appspot.com/4661051
-`,
-}
-
-func stringssplit(f *ast.File) bool {
- if !imports(f, "bytes") && !imports(f, "strings") {
- return false
- }
-
- fixed := false
- walk(f, func(n interface{}) {
- call, ok := n.(*ast.CallExpr)
- // func Split(s, sep string, n int) []string
- // func SplitAfter(s, sep string, n int) []string
- if !ok || len(call.Args) != 3 {
- return
- }
- // Is this our function?
- switch {
- case isPkgDot(call.Fun, "bytes", "Split"):
- case isPkgDot(call.Fun, "bytes", "SplitAfter"):
- case isPkgDot(call.Fun, "strings", "Split"):
- case isPkgDot(call.Fun, "strings", "SplitAfter"):
- default:
- return
- }
-
- sel := call.Fun.(*ast.SelectorExpr)
- args := call.Args
- fixed = true // We're committed.
-
- // Is the last argument -1? If so, drop the arg.
- // (Actually we just look for a negative integer literal.)
- // Otherwise, Split->SplitN and keep the arg.
- final := args[2]
- if unary, ok := final.(*ast.UnaryExpr); ok && unary.Op == token.SUB {
- if lit, ok := unary.X.(*ast.BasicLit); ok {
- // Is it an integer? If so, it's a negative integer and that's what we're after.
- if lit.Kind == token.INT {
- // drop the last arg.
- call.Args = args[0:2]
- return
- }
- }
- }
-
- // If not, rename and keep the argument list.
- sel.Sel.Name += "N"
- })
- return fixed
-}