Avoid is_constant calls in vectorizable_bswap
[official-gcc.git] / libgo / go / strings / compare.go
blob1fe6b8d89a3f94439a80ed2aa68456be4cba241b
1 // Copyright 2015 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.
5 package strings
7 // Compare returns an integer comparing two strings lexicographically.
8 // The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
9 //
10 // Compare is included only for symmetry with package bytes.
11 // It is usually clearer and always faster to use the built-in
12 // string comparison operators ==, <, >, and so on.
13 func Compare(a, b string) int {
14 // NOTE(rsc): This function does NOT call the runtime cmpstring function,
15 // because we do not want to provide any performance justification for
16 // using strings.Compare. Basically no one should use strings.Compare.
17 // As the comment above says, it is here only for symmetry with package bytes.
18 // If performance is important, the compiler should be changed to recognize
19 // the pattern so that all code doing three-way comparisons, not just code
20 // using strings.Compare, can benefit.
21 if a == b {
22 return 0
24 if a < b {
25 return -1
27 return +1