#183 ✓invalid
John-David Dalton

Remove indexOf from Enumerable#include because it uses strict equality

Reported by John-David Dalton | June 24th, 2008 @ 05:43 PM | in 1.7

Garret Smith pointed out that the use of this.indexOf uses strict equality if its being used on an array. So I have patched the method to remove this usage.

Comments and changes to this ticket

  • John-David Dalton
  • John-David Dalton

    John-David Dalton June 25th, 2008 @ 03:13 PM

    • State changed from “new” to “bug”
    • Tag set to patched
  • Tobie Langel

    Tobie Langel June 27th, 2008 @ 03:09 AM

    • State changed from “bug” to “enhancement”
    • Tag changed from patched to needs_benchmarks, needs_failing_test_case, needs_tests, patched
    • Milestone changed from 1.6.0.3 to 1.7

    Use of indexOf here is for perf reasons. (And yes, this would need real benchmarks.)

    Other than that, there's no reason for this to return incorrect results.

  • Juriy Zaytsev

    Juriy Zaytsev June 27th, 2008 @ 04:08 AM

    It certainly is weird to perform another loop if "indexOf == -1". Why can't we just return its result if method is present?

  • John-David Dalton

    John-David Dalton June 27th, 2008 @ 04:21 AM

    Ya Garrett mentioned that too.

    Though now that I look at it.

    If it failed the "indexOf" (which could be caused by it not meeting the strict equality), it will be looped again manually and it should pick up the match that way. Was this done by design?

    If so and the "indexOf" is more of a performance boost (I can see where this ticket is totally not needed).

  • Juriy Zaytsev

    Juriy Zaytsev June 27th, 2008 @ 04:30 AM

    This is one of the reasons why we need a better documentation.

    It's often not clear whether something was made intentionally or by mistake : )

  • John-David Dalton

    John-David Dalton June 27th, 2008 @ 05:19 PM

    • State changed from “enhancement” to “invalid”

    I am marking this invalid because if it fails the strict equality of indexOf it falls back on the traditional for loop scan.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:26 AM

    • Tag changed from needs_benchmarks, needs_failing_test_case, needs_tests, patched to missing:tests, needs_benchmarks, needs_failing_test_case, patched

    [not-tagged:"needs_tests" tagged:"missing:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:27 AM

    • Tag changed from missing:tests, needs_benchmarks, needs_failing_test_case, patched to missing:benchmarks, missing:tests, needs_failing_test_case, patched

    [not-tagged:"needs_benchmarks" tagged:"missing:benchmarks" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:36 AM

    • Tag changed from missing:benchmarks, missing:tests, needs_failing_test_case, patched to missing:benchmarks, needs:tests, needs_failing_test_case, patched

    [not-tagged:"missing:tests" tagged:"needs:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:39 AM

    • Tag changed from missing:benchmarks, needs:tests, needs_failing_test_case, patched to needs:benchmarks, needs:tests, needs_failing_test_case, patched

    [not-tagged:"missing:benchmarks" tagged:"needs:benchmarks" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:40 AM

    • Tag changed from needs:benchmarks, needs:tests, needs_failing_test_case, patched to needs:benchmarks, needs:failing_testcase, needs:tests, patched

    [not-tagged:"needs_failing_test_case" tagged:"needs:failing_testcase" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages