Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slices: add Concat #60929

Closed
wants to merge 3 commits into from
Closed

Conversation

earthboundkid
Copy link
Contributor

Fixes #56353

@gopherbot
Copy link
Contributor

This PR (HEAD: 91b9862) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/504882 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Xu Liu:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: f48e5da) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/504882 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Cuong Manh Le:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Xu Liu:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: fd860fc) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/504882 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

my implementation uses copy instead of append

func MergeSlices[T any](slices ...[]T) []T {
	sl := 0
	for i := range slices {
		sl += len(slices[i])
	}
	result := make([]T, sl)
	cp := 0
	for _, s := range slices {
		if sLen := len(s); sLen != 0 {
			copy(result[cp:], s)
			cp += sLen
		}
	}
	return result
}

this should result in no new mem allocs if Im right

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

should I send new pull or work on this?

@randall77
Copy link
Contributor

I don't think your implementation is any different than https://go-review.googlesource.com/c/go/+/504882
They both do exactly one allocation of the result size.

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

as there was no work done since ... I submitted my own impl. adjusted and simplified to meet the criteria -> #61817

@earthboundkid
Copy link
Contributor Author

AFAIK, the CL is just on hold because Go 1.21 isn't out quite yet. It should be reviewed and merged soon, then you can do a CL to add new tests or benchmarks.

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

ah that's why you did not work on it - sorry

@carlmjohnson should I add you as co-author to my patch or do you update yours ?!?

@earthboundkid
Copy link
Contributor Author

I don't see a reason to update to match yours without a benchmark that shows that it's faster. Write a benchmark and then open a new CL that stacks on top of mine.

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

well this need a patch anyway ... as your pull has this api
func Concat[S ~[]E, E any](slices ...S) S {}

and proposed is
func Concat[S ~[]E, E any](dst S, slices ...S) S {

not sure what has to be done when an accepted proposal has to be adjusted ?!?

@6543
Copy link
Contributor

6543 commented Aug 7, 2023

PS: I'll write some benchmarks :)

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@earthboundkid
Copy link
Contributor Author

well this need a patch anyway ... as your pull has this api func Concat[S ~[]E, E any](slices ...S) S {}

Read the full discussion. This was the accepted API. The dst slice turned out to be unworkable because of the aliasing problem.

@gopherbot
Copy link
Contributor

This PR (HEAD: e98968a) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/504882.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to register for Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 4: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 4: TryBot-Result-1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 96a35e5) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/504882.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to register for Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Carl Johnson:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 5: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 5: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 5: Auto-Submit+1 Code-Review+2 Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/504882.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Aug 8, 2023
Fixes #56353

Change-Id: I985e1553e7b02237403b833e96fb5ceec890f5b8
GitHub-Last-Rev: 96a35e5
GitHub-Pull-Request: #60929
Reviewed-on: https://go-review.googlesource.com/c/go/+/504882
Auto-Submit: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/504882 has been merged.

@gopherbot gopherbot closed this Aug 8, 2023
@earthboundkid
Copy link
Contributor Author

@6543 slices.Concat has been added. Feel free to open a performance boost CL. Those don't need to go through the proposal process. You just need to demonstrate that it's faster, and it can be merged.

@earthboundkid earthboundkid deleted the cj/concat branch August 8, 2023 14:44
@6543 6543 mentioned this pull request Aug 8, 2023
eric pushed a commit to fancybits/go that referenced this pull request Sep 7, 2023
Fixes golang#56353

Change-Id: I985e1553e7b02237403b833e96fb5ceec890f5b8
GitHub-Last-Rev: 96a35e5
GitHub-Pull-Request: golang#60929
Reviewed-on: https://go-review.googlesource.com/c/go/+/504882
Auto-Submit: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
eric pushed a commit to fancybits/go that referenced this pull request Sep 7, 2023
Fixes golang#56353

Change-Id: I985e1553e7b02237403b833e96fb5ceec890f5b8
GitHub-Last-Rev: 96a35e5
GitHub-Pull-Request: golang#60929
Reviewed-on: https://go-review.googlesource.com/c/go/+/504882
Auto-Submit: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
eric pushed a commit to fancybits/go that referenced this pull request Dec 23, 2023
Fixes golang#56353

Change-Id: I985e1553e7b02237403b833e96fb5ceec890f5b8
GitHub-Last-Rev: 96a35e5
GitHub-Pull-Request: golang#60929
Reviewed-on: https://go-review.googlesource.com/c/go/+/504882
Auto-Submit: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slices: add Concat
4 participants