diff options
| author | apocelipes <seve3r@outlook.com> | 2024-08-02 11:33:30 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-08-03 01:05:29 +0000 |
| commit | 9cfe3a86d34f7f4a401dae9a22389b12f7e8bb2e (patch) | |
| tree | ee37929c8da7d97a57085a86eb3838e8dd9e9449 /src/cmd/compile/internal/staticdata/embed.go | |
| parent | c61ff290dbfa6dab4928c0b273db18fddb10df37 (diff) | |
| download | go-9cfe3a86d34f7f4a401dae9a22389b12f7e8bb2e.tar.xz | |
archive/zip,cmd/compile: simplify the split function
Use strings to simplify the code.
This is a follow-up for the CL 586715.
Change-Id: I9e5470ec271e8af1ad4ddbb5f01f43a8a4879557
GitHub-Last-Rev: b95d6179781053ea8ec9fc8ad2e18607fd35c5bb
GitHub-Pull-Request: golang/go#68713
Reviewed-on: https://go-review.googlesource.com/c/go/+/602697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/cmd/compile/internal/staticdata/embed.go')
| -rw-r--r-- | src/cmd/compile/internal/staticdata/embed.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/staticdata/embed.go b/src/cmd/compile/internal/staticdata/embed.go index a4d493ce5e..be939db877 100644 --- a/src/cmd/compile/internal/staticdata/embed.go +++ b/src/cmd/compile/internal/staticdata/embed.go @@ -80,14 +80,8 @@ func embedKind(typ *types.Type) int { } func embedFileNameSplit(name string) (dir, elem string, isDir bool) { - if name[len(name)-1] == '/' { - isDir = true - name = name[:len(name)-1] - } - i := len(name) - 1 - for i >= 0 && name[i] != '/' { - i-- - } + name, isDir = strings.CutSuffix(name, "/") + i := strings.LastIndexByte(name, '/') if i < 0 { return ".", name, isDir } |
