]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gofix -r mapdelete
authorRuss Cox <rsc@golang.org>
Tue, 18 Oct 2011 13:56:34 +0000 (09:56 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 18 Oct 2011 13:56:34 +0000 (09:56 -0400)
R=golang-dev, r, adg, r, cw
CC=golang-dev
https://golang.org/cl/5266045

28 files changed:
src/cmd/cgo/gcc.go
src/cmd/gofmt/rewrite.go
src/pkg/debug/dwarf/type.go
src/pkg/exp/types/check_test.go
src/pkg/exp/types/universe.go
src/pkg/gob/decode.go
src/pkg/gob/type.go
src/pkg/http/fcgi/child.go
src/pkg/http/persist.go
src/pkg/http/transfer.go
src/pkg/http/transport.go
src/pkg/net/fd.go
src/pkg/net/fd_linux.go
src/pkg/net/textproto/header.go
src/pkg/net/textproto/pipeline.go
src/pkg/old/netchan/export.go
src/pkg/old/netchan/import.go
src/pkg/os/inotify/inotify_linux.go
src/pkg/reflect/type.go
src/pkg/rpc/client.go
src/pkg/rpc/jsonrpc/client.go
src/pkg/rpc/jsonrpc/server.go
src/pkg/syscall/syscall_unix.go
src/pkg/unicode/maketables.go
src/pkg/unicode/script_test.go
src/pkg/url/url.go
src/pkg/xml/xml.go
test/nil.go

index 90f4032b256c91e1ac4aeab08d9114e187e9bcd4..1864eed09afb2407bf8fa10c2cfc614a60347c8a 100644 (file)
@@ -588,7 +588,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
                                n.Const = strconv.Itoa64(n.Type.EnumValues[k])
                                // Remove injected enum to ensure the value will deep-compare
                                // equally in future loads of the same constant.
-                               n.Type.EnumValues[k] = 0, false
+                               delete(n.Type.EnumValues, k)
                        } else if n.Kind == "const" && i < len(enumVal) {
                                n.Const = strconv.Itoa64(enumVal[i])
                        }
index 8f65ef1ff1e7ae4a6262babc74e45a4a43bfe53d..7f2bf0647a4f843a17f76fc561ca8d2bbcc73a6a 100644 (file)
@@ -65,7 +65,7 @@ func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
                        return reflect.Value{}
                }
                for k := range m {
-                       m[k] = reflect.Value{}, false
+                       delete(m, k)
                }
                val = apply(f, val)
                if match(m, pat, val) {
index f35365ebeb08cd709200777ea0e07efb5d80d322..9fa221b090252e21307734dada6f57a7d32bed1a 100644 (file)
@@ -579,6 +579,6 @@ Error:
        // If the parse fails, take the type out of the cache
        // so that the next call with this offset doesn't hit
        // the cache and return success.
-       d.typeCache[off] = nil, false
+       delete(d.typeCache, off)
        return nil, err
 }
index 8be653fcb665542132c6c64ba1556e4899d4839e..034acd00de5a30bd7488499a9de5abe0bca57b68 100644 (file)
@@ -154,7 +154,7 @@ func eliminate(t *testing.T, expected map[token.Pos]string, errors os.Error) {
                                continue
                        }
                        // we have a match - eliminate this error
-                       expected[pos] = "", false
+                       delete(expected, pos)
                } else {
                        // To keep in mind when analyzing failed test output:
                        // If the same error position occurs multiple times in errors,
index 6ae88e5f9c29ea6680db59b0f6faac6df3511e51..80db127829585f982b5f5e22433e0d1aac071ab6 100644 (file)
@@ -81,6 +81,7 @@ func init() {
        defFun("close")
        defFun("complex")
        defFun("copy")
+       defFun("delete")
        defFun("imag")
        defFun("len")
        defFun("make")
index 9d8d9058747a190092cd5c1729c7e2d35beaeac6..f480087836ef5d908f6f49cc1639ea720bf1b2a7 100644 (file)
@@ -1154,7 +1154,7 @@ func (dec *Decoder) getDecEnginePtr(remoteId typeId, ut *userTypeInfo) (enginePt
                decoderMap[remoteId] = enginePtr
                *enginePtr, err = dec.compileDec(remoteId, ut)
                if err != nil {
-                       decoderMap[remoteId] = nil, false
+                       delete(decoderMap, remoteId)
                }
        }
        return
@@ -1179,7 +1179,7 @@ func (dec *Decoder) getIgnoreEnginePtr(wireId typeId) (enginePtr **decEngine, er
                        *enginePtr, err = dec.compileIgnoreSingle(wireId)
                }
                if err != nil {
-                       dec.ignorerCache[wireId] = nil, false
+                       delete(dec.ignorerCache, wireId)
                }
        }
        return
index b2f716c4b5d97aa4e9a132f2d861ee7925081501..870101e20ca65c4905fcf8ef2058271acbf93ce5 100644 (file)
@@ -405,7 +405,7 @@ func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, os.
        var type0, type1 gobType
        defer func() {
                if err != nil {
-                       types[rt] = nil, false
+                       delete(types, rt)
                }
        }()
        // Install the top-level type before the subtypes (e.g. struct before
index 19718824c96f863989ef3e913812f8804fddb47b..61dd3fbdc435e47b1d70c8ed41e7dc3d2a15c2d8 100644 (file)
@@ -194,7 +194,7 @@ func (c *child) serve() {
                case typeData:
                        // If the filter role is implemented, read the data stream here.
                case typeAbortRequest:
-                       requests[rec.h.Id] = nil, false
+                       delete(requests, rec.h.Id)
                        c.conn.writeEndRequest(rec.h.Id, 0, statusRequestComplete)
                        if !req.keepConn {
                                // connection will close upon return
index 78bf9058f3c32fa525debe44680d7aa98f918503..f73e6c63c567caf53c8b043a91a22163e93f4fb3 100644 (file)
@@ -165,7 +165,7 @@ func (sc *ServerConn) Write(req *Request, resp *Response) os.Error {
        // Retrieve the pipeline ID of this request/response pair
        sc.lk.Lock()
        id, ok := sc.pipereq[req]
-       sc.pipereq[req] = 0, false
+       delete(sc.pipereq, req)
        if !ok {
                sc.lk.Unlock()
                return ErrPipeline
@@ -353,7 +353,7 @@ func (cc *ClientConn) readUsing(req *Request, readRes func(*bufio.Reader, *Reque
        // Retrieve the pipeline ID of this request/response pair
        cc.lk.Lock()
        id, ok := cc.pipereq[req]
-       cc.pipereq[req] = 0, false
+       delete(cc.pipereq, req)
        if !ok {
                cc.lk.Unlock()
                return nil, ErrPipeline
index 300c7a88d5eedc8d950db8e770232302e037d58c..868a1143fd91ce4a975638de0e3648524afb22bf 100644 (file)
@@ -366,7 +366,7 @@ func fixTransferEncoding(requestMethod string, header Header) ([]string, os.Erro
                return nil, nil
        }
 
-       header["Transfer-Encoding"] = nil, false
+       delete(header, "Transfer-Encoding")
 
        // Head responses have no bodies, so the transfer encoding
        // should be ignored.
@@ -399,7 +399,7 @@ func fixTransferEncoding(requestMethod string, header Header) ([]string, os.Erro
                // Chunked encoding trumps Content-Length. See RFC 2616
                // Section 4.4. Currently len(te) > 0 implies chunked
                // encoding.
-               header["Content-Length"] = nil, false
+               delete(header, "Content-Length")
                return te, nil
        }
 
index b0aea970873073d344b61ff35c12d0fc8453cf63..0914af7e5cfe31d16a3dd30341ec8a79db85fd24 100644 (file)
@@ -266,7 +266,7 @@ func (t *Transport) getIdleConn(cm *connectMethod) (pconn *persistConn) {
                }
                if len(pconns) == 1 {
                        pconn = pconns[0]
-                       t.idleConn[key] = nil, false
+                       delete(t.idleConn, key)
                } else {
                        // 2 or more cached connections; pop last
                        // TODO: queue?
index e46e1203a5158ce49cf5369b19a1a294597e7dd9..80d40af766286b4bd93e6aa8311180209475cb01 100644 (file)
@@ -152,7 +152,7 @@ func (s *pollServer) LookupFD(fd int, mode int) *netFD {
        if !ok {
                return nil
        }
-       s.pending[key] = nil, false
+       delete(s.pending, key)
        return netfd
 }
 
@@ -195,7 +195,7 @@ func (s *pollServer) CheckDeadlines() {
                }
                if t > 0 {
                        if t <= now {
-                               s.pending[key] = nil, false
+                               delete(s.pending, key)
                                if mode == 'r' {
                                        s.poll.DelFD(fd.sysfd, mode)
                                        fd.rdeadline = -1
index 70fc344b2a0b61ffd147a2330a22abf06e6bd641..c860c842af73640e524157eb577b12731be073c3 100644 (file)
@@ -105,7 +105,7 @@ func (p *pollster) StopWaiting(fd int, bits uint) {
                if e := syscall.EpollCtl(p.epfd, syscall.EPOLL_CTL_DEL, fd, nil); e != 0 {
                        print("Epoll delete fd=", fd, ": ", os.Errno(e).String(), "\n")
                }
-               p.events[fd] = 0, false
+               delete(p.events, fd)
        }
 }
 
index 288deb2ceb49c13dcb0a0354a120dc08d9307344..7fb32f8045e82d929cc436d514cbf1a5e266c6f4 100644 (file)
@@ -39,5 +39,5 @@ func (h MIMEHeader) Get(key string) string {
 
 // Del deletes the values associated with key.
 func (h MIMEHeader) Del(key string) {
-       h[CanonicalMIMEHeaderKey(key)] = nil, false
+       delete(h, CanonicalMIMEHeaderKey(key))
 }
index 8c25884b3bfe7430f072475519e189c9834d2dc6..ca50eddac3860515d30ece69ed12256d8f6ae1cb 100644 (file)
@@ -108,7 +108,7 @@ func (s *sequencer) End(id uint) {
        }
        c, ok := s.wait[id]
        if ok {
-               s.wait[id] = nil, false
+               delete(s.wait, id)
        }
        s.mu.Unlock()
        if ok {
index 7df736515360be7fadf4b55b9e287bd8074a08a9..99d5d7e05d1d3d4458fb62fa0cbd67fb6fa174b7 100644 (file)
@@ -314,7 +314,7 @@ func (exp *Exporter) addClient(conn io.ReadWriter) *expClient {
 // delClient forgets the client existed
 func (exp *Exporter) delClient(client *expClient) {
        exp.mu.Lock()
-       exp.clients[client] = false, false
+       delete(exp.clients, client)
        exp.mu.Unlock()
 }
 
@@ -388,7 +388,7 @@ func (exp *Exporter) Hangup(name string) os.Error {
        exp.mu.Lock()
        chDir, ok := exp.names[name]
        if ok {
-               exp.names[name] = nil, false
+               delete(exp.names, name)
        }
        // TODO drop all instances of channel from client sets
        exp.mu.Unlock()
index ec17d97774ba37201e7d6587fc14d87ed85aa2fb..5a459e0d5ac9bcd1b985d989adfe2637dc719587 100644 (file)
@@ -256,8 +256,8 @@ func (imp *Importer) Hangup(name string) os.Error {
        if nc == nil {
                return os.NewError("netchan import: hangup: no such channel: " + name)
        }
-       imp.names[name] = nil, false
-       imp.chans[nc.id] = nil, false
+       delete(imp.names, name)
+       delete(imp.chans, nc.id)
        nc.close()
        return nil
 }
index 99fa5162223084ef7a58320ccbe1d7e7505f70b9..ee3c75f63b131a98a7ef1e06c43b93ff682eb5e8 100644 (file)
@@ -131,7 +131,7 @@ func (w *Watcher) RemoveWatch(path string) os.Error {
        if success == -1 {
                return os.NewSyscallError("inotify_rm_watch", errno)
        }
-       w.watches[path] = nil, false
+       delete(w.watches, path)
        return nil
 }
 
index 3630069bba2837067049be3717a901aad404f66a..be5477d243d00e3a4ca075a4adbb55e3264fd1de 100644 (file)
@@ -876,7 +876,7 @@ L:
                fd = inf
        }
 
-       mark[t] = false, false
+       delete(mark, t)
        return
 }
 
index 4acfdf6d9627a6e3deb59ac4f598b7da482950e6..c77901c6dca8f9c946a4ca7ee043cf0f87667dc1 100644 (file)
@@ -104,7 +104,7 @@ func (client *Client) input() {
                seq := response.Seq
                client.mutex.Lock()
                c := client.pending[seq]
-               client.pending[seq] = c, false
+               delete(client.pending, seq)
                client.mutex.Unlock()
 
                if response.Error == "" {
index 577d0ce4295b60095f1af6cd379e693156d967ce..17e9b9388a0811e512dea5a3090b790d10d11998 100644 (file)
@@ -79,7 +79,7 @@ func (c *clientCodec) ReadResponseHeader(r *rpc.Response) os.Error {
 
        c.mutex.Lock()
        r.ServiceMethod = c.pending[c.resp.Id]
-       c.pending[c.resp.Id] = "", false
+       delete(c.pending, c.resp.Id)
        c.mutex.Unlock()
 
        r.Error = ""
index 9801fdf221ef5471d29b79a8b8bfbce4b1384409..61b5abff5515d87458dbf12ac3fb9267468db27a 100644 (file)
@@ -107,7 +107,7 @@ func (c *serverCodec) WriteResponse(r *rpc.Response, x interface{}) os.Error {
                c.mutex.Unlock()
                return os.NewError("invalid sequence number in response")
        }
-       c.pending[r.Seq] = nil, false
+       delete(c.pending, r.Seq)
        c.mutex.Unlock()
 
        if b == nil {
index 1590b6d4f2a12ccc011775a483f103da2e50a2fb..70ea3bd69ae8e616b8334be49d182a7e37aeaf32 100644 (file)
@@ -87,6 +87,6 @@ func (m *mmapper) Munmap(data []byte) (errno int) {
        if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != 0 {
                return errno
        }
-       m.active[p] = nil, false
+       delete(m.active, p)
        return 0
 }
index 087422de383227f2af70824305415e6a303633c9..15579aa83c78926ec1c93cd550f5e729b89ba090 100644 (file)
@@ -1152,7 +1152,7 @@ func foldExceptions(class []int) map[int]bool {
 
        // Remove class itself.
        for _, r := range class {
-               m[r] = false, false
+               delete(m, r)
        }
 
        // What's left is the exceptions.
index b37ad183615775695aa28276258c9241717eac5c..dfd636d8399a3bc667abc917cc7633e90da5af5c 100644 (file)
@@ -206,7 +206,7 @@ func TestScripts(t *testing.T) {
                if !Is(Scripts[test.script], test.rune) {
                        t.Errorf("IsScript(%U, %s) = false, want true", test.rune, test.script)
                }
-               notTested[test.script] = false, false
+               delete(notTested, test.script)
        }
        for _, test := range outTest {
                if Is(Scripts[test.script], test.rune) {
@@ -230,7 +230,7 @@ func TestCategories(t *testing.T) {
                if !Is(Categories[test.script], test.rune) {
                        t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
                }
-               notTested[test.script] = false, false
+               delete(notTested, test.script)
        }
        for k := range notTested {
                t.Error("category not tested:", k)
@@ -249,7 +249,7 @@ func TestProperties(t *testing.T) {
                if !Is(Properties[test.script], test.rune) {
                        t.Errorf("IsCategory(%U, %s) = false, want true", test.rune, test.script)
                }
-               notTested[test.script] = false, false
+               delete(notTested, test.script)
        }
        for k := range notTested {
                t.Error("property not tested:", k)
index 9d193482ce4d3d05c559ffd83af3021977e66f27..dd1f93d14c4209d3c4059fe2dd2bf16d1aed7640 100644 (file)
@@ -517,7 +517,7 @@ func (v Values) Add(key, value string) {
 
 // Del deletes the values associated with key.
 func (v Values) Del(key string) {
-       v[key] = nil, false
+       delete(v, key)
 }
 
 // ParseQuery parses the URL-encoded query string and returns
index e7ba44e4a269090516e507d76539c66de5b0f3c7..85c24bc45039486ac400afe3aba0d6e1aebd45ca 100644 (file)
@@ -390,7 +390,11 @@ func (p *Parser) popElement(t *EndElement) bool {
        // translations that were associated with the element we just closed.
        for p.stk != nil && p.stk.kind != stkStart {
                s := p.pop()
-               p.ns[s.name.Local] = s.name.Space, s.ok
+               if s.ok {
+                       p.ns[s.name.Local] = s.name.Space
+               } else {
+                       delete(p.ns, s.name.Local)
+               }
        }
 
        return true
index 30cc2705b03b11a34eeb349c5586ee35fa67d209..efcf4f7822b08c2672ae647c01342a40b8a7023d 100644 (file)
@@ -150,7 +150,7 @@ func maptest() {
                m[2] = 3
        })
        shouldPanic(func() {
-               m[2] = 0, false
+               delete(m, 2)
        })
 }