Ignore:
Timestamp:
Jul 12, 2011, 5:39:52 AM (14 years ago)
Author:
Adam Roben
Message:

Unreviewed, rolling out r90811.
http://trac.webkit.org/changeset/90811
https://bugs.webkit.org/show_bug.cgi?id=61025

Several svg tests failing assertions beneath
SVGSMILElement::findInstanceTime

Source/JavaScriptCore:

  • wtf/StdLibExtras.h:

(WTF::binarySearch):

Source/WebCore:

  • svg/animation/SVGSMILElement.cpp:

(WebCore::SVGSMILElement::findInstanceTime):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wtf/StdLibExtras.h

    r90811 r90812  
    124124}
    125125
    126 enum BinarySearchMode {
    127     KeyMustBePresentInArray,
    128     KeyMustNotBePresentInArray
    129 };
    130 
    131126// Binary search algorithm, calls extractKey on pre-sorted elements in array,
    132127// compares result with key (KeyTypes should be comparable with '--', '<', '>').
     128// Optimized for cases where the array contains the key, checked by assertions.
    133129template<typename ArrayType, typename KeyType, KeyType(*extractKey)(ArrayType*)>
    134 inline ArrayType* binarySearch(ArrayType* array, size_t size, KeyType key, BinarySearchMode mode = KeyMustBePresentInArray)
     130inline ArrayType* binarySearch(ArrayType* array, size_t size, KeyType key)
    135131{
    136     // The array must contain at least one element (pre-condition, array does contain key).
    137     // If the array contains only one element, no need to do the comparison.
     132    // The array must contain at least one element (pre-condition, array does conatin key).
     133    // If the array only contains one element, no need to do the comparison.
    138134    while (size > 1) {
    139135        // Pick an element to check, half way through the array, and read the value.
    140136        int pos = (size - 1) >> 1;
    141137        KeyType val = extractKey(&array[pos]);
    142 
     138       
    143139        // If the key matches, success!
    144140        if (val == key)
     
    154150        }
    155151
    156         // In case of BinarySearchMode = KeyMustBePresentInArray 'size' should never reach zero.
    157         if (mode == KeyMustBePresentInArray)
    158             ASSERT(size);
     152        // 'size' should never reach zero.
     153        ASSERT(size);
    159154    }
    160 
    161     // In case of BinarySearchMode = KeyMustBePresentInArray if we reach this point
    162     // we've chopped down to one element, no need to check it matches
    163     if (mode == KeyMustBePresentInArray) {
    164         ASSERT(size == 1);
    165         ASSERT(key == extractKey(&array[0]));
    166     }
    167 
     155   
     156    // If we reach this point we've chopped down to one element, no need to check it matches
     157    ASSERT(size == 1);
     158    ASSERT(key == extractKey(&array[0]));
    168159    return &array[0];
    169160}
Note: See TracChangeset for help on using the changeset viewer.