REBOL3 tracker
  0.9.12 beta
Ticket #0001720 User: anonymous

Project:



rss
TypeWish Statusreviewed Date26-Oct-2010 23:08
Versionalpha 109 CategoryNative Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary FIND /same option
Description The /same option would search for the SAME? value in a block-like series, rather than an equivalent value. For other types that FIND applies to, /same would be a noop because the equivalence tested is the same one used by SAME? already. This should be even faster than a normal FIND.

This request is partly in response to #1708.
Example code
; Example code:
find/same b :val

; Equivalent code:
forall b [if same? :val first b [break/return b]]


Assigned ton/a Fixed in- Last Update2-Nov-2010 01:39


Comments
(0002667)
maxim
26-Oct-2010 23:20

YESSSS

I've had to make this using a looped find and same?

it is orders of magnitude faster on searches, when items from a dataset have to be searched in said dataset. example, to get the new index after some sorting algorithm, or to get a row from a db search when your criteria is the result of a query in that database.

its also useful in GUIs to determine selection from a list which has several times the same text but from different sources.
(0002668)
maxim
26-Oct-2010 23:28

this is much faster than above example

until [either (same? pick (r: find blk :val) 1 :val) [r][not blk: :r]]
(0002669)
BrianH
26-Oct-2010 23:37

That would not be faster for blocks that contain a lot of references to equivalent but not the same object/module/block/whatever as the value you are looking for. The FIND does a full EQUAL?-style comparison, and enough of those add up quickly. SAME? is much faster than EQUAL?.
(0002746)
maxim
2-Nov-2010 01:39

I know SAME? is faster, but going through REBOL loops was soo much slower than FIND that except for that specific case you gave, it was several hundred times faster in most cases, the larger the series, the bigger the difference.

having FIND/SAME would make that several times faster on ALL datatypes, which is why I'd be really happy for this wish to be granted. :-)


Date User Field Action Change
2-Nov-2010 01:41 maxim Comment : 0002746 Modified -
2-Nov-2010 01:39 maxim Comment : 0002746 Added -
26-Oct-2010 23:37 BrianH Comment : 0002669 Added -
26-Oct-2010 23:28 carl Status Modified submitted => reviewed
26-Oct-2010 23:28 maxim Comment : 0002668 Added -
26-Oct-2010 23:20 maxim Comment : 0002667 Added -
26-Oct-2010 23:13 BrianH Description Modified -
26-Oct-2010 23:11 BrianH Description Modified -
26-Oct-2010 23:11 BrianH Code Modified -
26-Oct-2010 23:08 BrianH Ticket Added -