Issue 7434 in pharo: collect:thenSelect: is badly implemented

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 7434 in pharo: collect:thenSelect: is badly implemented

pharo
Status: Accepted
Owner: [hidden email]
Labels: Type-Cleanup

New issue 7434 by [hidden email]: collect:thenSelect: is badly  
implemented
http://code.google.com/p/pharo/issues/detail?id=7434

collect: collectBlock thenSelect: selectBlock
        "Utility method to improve readability."

        ^ (self collect: collectBlock) select: selectBlock

where it should iterate only once over the collection

sth like

| result |
result := self class new.
self do: [:e || value |
      value := collectBlock value: e.
     (selectBlock value: value) ifTrue: [ result add: value ]]

no ?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7434 in pharo: collect:thenSelect: is badly implemented

pharo

Comment #1 on issue 7434 by [hidden email]: collect:thenSelect: is  
badly implemented
http://code.google.com/p/pharo/issues/detail?id=7434

After a little bit of investigation, that's the way it's implemented in  
OrderedCollection.

Why not for others ?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7434 in pharo: collect:thenSelect: is badly implemented

pharo
Updates:
        Status: Invalid

Comment #2 on issue 7434 by [hidden email]: collect:thenSelect: is  
badly implemented
http://code.google.com/p/pharo/issues/detail?id=7434

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7434 in pharo: collect:thenSelect: is badly implemented

pharo
Updates:
        Status: Accepted
        Labels: Target-Collection

Comment #3 on issue 7434 by [hidden email]: collect:thenSelect: is  
badly implemented
http://code.google.com/p/pharo/issues/detail?id=7434

no, indeed this is bad!
=> using the streaming protocol should always work:

self class streamContents: [ :s|
     self do: [ :o|
      value := collectBlock value: o.
     (selectBlock value: value) ifTrue: [ s nextPut: value ]]]

=> we should measure the overhead?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker