[Bug 27712] IndexedDB: Array comparison algorithm doesn't handle empty arrays

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27712

Joshua Bell <jsbell@google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jsbell@google.com
           Assignee|dave.null@w3.org            |jsbell@google.com

--- Comment #1 from Joshua Bell <jsbell@google.com> ---
Simplest fix: insert new step 3 and update 4->5

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A's length and B's length.
3. If length is 0, go to step 9.
4. Let i be 0.
5. If the ith value of A is less than the ith value of B, then A is less than
B. Skip the remaining steps.
6. If the ith value of A is greater than the ith value of B, then A is greater
than B. Skip the remaining steps.
7. Increase i by 1.
8. If i is not equal to length, go back to step 5. Otherwise continue to next
step.
9. If A's length is less than B's length, then A is less than B. If A's length
is greater than B's length, then A is greater than B. Otherwise A and B are
equal.

Alternately:

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A's length and B's length.
3. Let i be 0.
4. If i is equal to length, go to step 9. Otherwise continue to next step.
5. If the ith value of A is less than the ith value of B, then A is less than
B. Skip the remaining steps.
6. If the ith value of A is greater than the ith value of B, then A is greater
than B. Skip the remaining steps.
7. Increase i by 1.
8. Go back to step 4.
9. If A's length is less than B's length, then A is less than B. If A's length
is greater than B's length, then A is greater than B. Otherwise A and B are
equal.

Or using a 'while' loop:

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A's length and B's length.
3. Let i be 0.
4. While i is less than length:
  1. If the ith value of A is less than the ith value of B, then A is less than
B. Skip the remaining steps.
  2. If the ith value of A is greater than the ith value of B, then A is
greater than B. Skip the remaining steps.
  3. Increase i by 1.
5. If A's length is less than B's length, then A is less than B. If A's length
is greater than B's length, then A is greater than B. Otherwise A and B are
equal.

I can fix in the ED if someone wants to select and sanity-check one of the
above.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 7 January 2015 18:52:07 UTC