Source file src/internal/bytealg/equal_generic.go

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package bytealg
     6  
     7  // Equal reports whether a and b
     8  // are the same length and contain the same bytes.
     9  // A nil argument is equivalent to an empty slice.
    10  //
    11  // Equal is equivalent to bytes.Equal.
    12  // It is provided here for convenience,
    13  // because some packages cannot depend on bytes.
    14  func Equal(a, b []byte) bool {
    15  	// Neither cmd/compile nor gccgo allocates for these string conversions.
    16  	// There is a test for this in package bytes.
    17  	return string(a) == string(b)
    18  }
    19  

View as plain text