mirror of
https://github.com/golang/go
synced 2024-11-22 02:54:39 -07:00
syscall: optimize Getwd on aix
When looking for \0, use clen which may be optimized. Also, return EINVAL when returned string is empty. This makes it similar to how it is implemented in *bsd and solaris. Change-Id: I3e37ed25f47110eafd12c80291f7746de9db7b23 Reviewed-on: https://go-review.googlesource.com/c/go/+/606902 TryBot-Bypass: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
b5ee80a85a
commit
4a9d98d49a
@ -119,11 +119,11 @@ func Getwd() (ret string, err error) {
|
||||
b := make([]byte, len)
|
||||
err := getcwd(&b[0], len)
|
||||
if err == nil {
|
||||
i := 0
|
||||
for b[i] != 0 {
|
||||
i++
|
||||
n := clen(b[:])
|
||||
if n < 1 {
|
||||
return "", EINVAL
|
||||
}
|
||||
return string(b[0:i]), nil
|
||||
return string(b[:n]), nil
|
||||
}
|
||||
if err != ERANGE {
|
||||
return "", err
|
||||
|
Loading…
Reference in New Issue
Block a user