Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(272)

Delta Between Two Patch Sets: src/pkg/bytes/bytes.go

Issue 3302042: code review 3302042: Removed bytes.Add and bytes.AddByte; we now have 'append'. (Closed)
Left Patch Set: Created 14 years, 3 months ago
Right Patch Set: code review 3302042: Removed bytes.Add and bytes.AddByte; we now have 'append'. Created 14 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « doc/effective_go.html ('k') | src/pkg/bytes/bytes_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // The bytes package implements functions for the manipulation of byte slices. 5 // The bytes package implements functions for the manipulation of byte slices.
6 // Analogous to the facilities of the strings package. 6 // Analogous to the facilities of the strings package.
7 package bytes 7 package bytes
8 8
9 import ( 9 import (
10 "unicode" 10 "unicode"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 func TrimRight(s []byte, cutset string) []byte { 545 func TrimRight(s []byte, cutset string) []byte {
546 return TrimRightFunc(s, makeCutsetFunc(cutset)) 546 return TrimRightFunc(s, makeCutsetFunc(cutset))
547 } 547 }
548 548
549 // TrimSpace returns a subslice of s by slicing off all leading and 549 // TrimSpace returns a subslice of s by slicing off all leading and
550 // trailing white space, as as defined by Unicode. 550 // trailing white space, as as defined by Unicode.
551 func TrimSpace(s []byte) []byte { 551 func TrimSpace(s []byte) []byte {
552 return TrimFunc(s, unicode.IsSpace) 552 return TrimFunc(s, unicode.IsSpace)
553 } 553 }
554 554
555 // Add appends the contents of t to the end of s and returns the result.
556 // If s has enough capacity, it is extended in place; otherwise a
557 // new array is allocated and returned.
558 func Add(s, t []byte) []byte { // TODO
559 return append(s, t...)
560 }
561
562 // AddByte appends byte t to the end of s and returns the result.
563 // If s has enough capacity, it is extended in place; otherwise a
564 // new array is allocated and returned.
565 func AddByte(s []byte, t byte) []byte { // TODO
566 return append(s, t)
567 }
568
569 // Runes returns a slice of runes (Unicode code points) equivalent to s. 555 // Runes returns a slice of runes (Unicode code points) equivalent to s.
570 func Runes(s []byte) []int { 556 func Runes(s []byte) []int {
571 t := make([]int, utf8.RuneCount(s)) 557 t := make([]int, utf8.RuneCount(s))
572 i := 0 558 i := 0
573 for len(s) > 0 { 559 for len(s) > 0 {
574 r, l := utf8.DecodeRune(s) 560 r, l := utf8.DecodeRune(s)
575 t[i] = r 561 t[i] = r
576 i++ 562 i++
577 s = s[l:] 563 s = s[l:]
578 } 564 }
(...skipping 28 matching lines...) Expand all
607 } else { 593 } else {
608 j += Index(s[start:], old) 594 j += Index(s[start:], old)
609 } 595 }
610 w += copy(t[w:], s[start:j]) 596 w += copy(t[w:], s[start:j])
611 w += copy(t[w:], new) 597 w += copy(t[w:], new)
612 start = j + len(old) 598 start = j + len(old)
613 } 599 }
614 w += copy(t[w:], s[start:]) 600 w += copy(t[w:], s[start:])
615 return t[0:w] 601 return t[0:w]
616 } 602 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b