You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove SliceConcatExt, add them as methods on [T]. #1141
BTW I'd very much like Iterator to have those methods instead. I know that would be less efficient than the current implementation. Maybe impl Iterator for slice::Iter could still salvage the more efficient implementation.
I meant that if I have some other data structure like a HashSet, I'd have to iterate through all the string and collect them (causing an allocation to occur I think?) before calling join on it
Yes. Notice that servo could use SliceConcatExt's join when it has a slice for a much more efficient join operation. It's only unfortunate that we can't offer both the efficient slice version and the less efficient iterator version in a single method call. Specialization could help.
Activity
gkoz commentedon May 31, 2015
Related PR: Rename connect to join.
BTW I'd very much like
Iteratorto have those methods instead. I know that would be less efficient than the current implementation. Maybeimpl Iterator for slice::Itercould still salvage the more efficient implementation.bluss commentedon Jun 12, 2015
Moving a method from an unstable trait to an inherent impl is a minor breaking change I guess.
This quirky stuff compiles because concat is on a prelude trait:
frewsxcv commentedon Sep 30, 2015
Here's how Servo joins strings. It's nice that it works directly with iterators to avoid unnecessary allocations
gkoz commentedon Sep 30, 2015
@frewsxcv
Is
push_strin that implementation not performing any reallocations? Ones thatSliceConcatExtis avoiding?bluss commentedon Sep 30, 2015
Right, the slice version avoids reallocation while building the string by iterating through to sum up the exact capacity needed up front.
frewsxcv commentedon Sep 30, 2015
I meant that if I have some other data structure like a
HashSet, I'd have to iterate through all the string and collect them (causing an allocation to occur I think?) before callingjoinon itbluss commentedon Sep 30, 2015
Yes. Notice that servo could use SliceConcatExt's join when it has a slice for a much more efficient
joinoperation. It's only unfortunate that we can't offer both the efficient slice version and the less efficient iterator version in a single method call. Specialization could help.