Thanks, but the mail client somewhat crippeled the code. Could you
file a ticket? http://dev.jquery.com/newticket (requires registration)

Thanks!

Jörn

On Wed, Oct 22, 2008 at 3:01 PM, markus.staab <[EMAIL PROTECTED]> wrote:
>
> updated patch:
>
> Index: testrunner.js
> ===================================================================
> --- testrunner.js       (revision 5903)
> +++ testrunner.js       (working copy)
> @@ -399,7 +399,7 @@
>     var args = Array.prototype.slice.apply(arguments);
>     var eq = true; // equivalent until we can explicitely say it's
> not!
>     var a, b; // compares a and b (1st and 2nd argument)
> -    var len; // for iterating array's length memoization
> +    var i, len; // for iterating over objects convenience and for
> iterating array's length memoization
>
>     if (args.length < 2) {
>         return true; // nothing to compare together
> @@ -428,8 +428,8 @@
>             if (len !== b.length) { // safe and faster
>                 return false;
>             }
> -            for (var i = 0; i < len; i++) {
> -                eq = eq && equiv(a[i], b[i]);
> +            for (i = 0; i < len && eq; i++) {
> +                eq = equiv(a[i], b[i]);
>             }
>             return eq;
>         }
> @@ -443,23 +443,26 @@
>         }
>
>         if (typeof a === "object") {
> -            // Verify properties equivalence in both ways:
> -
> -            // Everything in a should be in b and equivalent and ...
> -            for (var i in a) {
> -                if (a.hasOwnProperty(i)) {
> -                    eq = eq && equiv(a[i], b[i]);
> -                }
> -            }
> -
> -            // ... everything in b should be in a and equivalent
> -            for (var i in b) {
> -                if (b.hasOwnProperty(i)) {
> -                    eq = eq && equiv(b[i], a[i]);
> -                }
> -            }
> -
> -            return eq;
> +            // With Markus Staab's help
> +            // see 
> http://groups.google.com/group/jquery-dev/browse_thread/thread/9447a950b40574f
> +
> +            // Verify a's properties with b's properties equivalence
> +            for (i in a) {
> +                if (a.hasOwnProperty(i)) {
> +                    if (!b.hasOwnProperty(i) || !equiv(a[i], b[i]))
> {
> +                        return false;
> +                    }
> +                }
> +            }
> +
> +            // Need only to verify that b's property are also a's
> property
> +            for (i in b) {
> +                if (b.hasOwnProperty(i) && !a.hasOwnProperty(i)) {
> +                    return false;
> +                }
> +            }
> +
> +            return true;
>         }
>
>         if (typeof a === "function") {
>
>
> missed a few lines of code.
>
> On 22 Okt., 14:53, "markus.staab" <[EMAIL PROTECTED]> wrote:
>> Hi Jörn,
>>
>> here it is:
>>
>> Index: testrunner.js
>> ===================================================================
>> --- testrunner.js       (revision 5903)
>> +++ testrunner.js       (working copy)
>> @@ -428,8 +428,8 @@
>>              if (len !== b.length) { // safe and faster
>>                  return false;
>>              }
>> -            for (var i = 0; i < len; i++) {
>> -                eq = eq && equiv(a[i], b[i]);
>> +            for (var i = 0; i < len && eq; i++) {
>> +                eq = equiv(a[i], b[i]);
>>              }
>>              return eq;
>>          }
>> @@ -443,23 +443,26 @@
>>          }
>>
>>          if (typeof a === "object") {
>> -            // Verify properties equivalence in both ways:
>> -
>> -            // Everything in a should be in b and equivalent and ...
>> -            for (var i in a) {
>> -                if (a.hasOwnProperty(i)) {
>> -                    eq = eq && equiv(a[i], b[i]);
>> -                }
>> -            }
>> -
>> -            // ... everything in b should be in a and equivalent
>> -            for (var i in b) {
>> -                if (b.hasOwnProperty(i)) {
>> -                    eq = eq && equiv(b[i], a[i]);
>> -                }
>> -            }
>> -
>> -            return eq;
>> +            // With Markus Staab's help
>> +            // 
>> seehttp://groups.google.com/group/jquery-dev/browse_thread/thread/9447a9...
>> +
>> +            // Verify a's properties with b's properties equivalence
>> +            for (i in a) {
>> +                if (a.hasOwnProperty(i)) {
>> +                    if (!b.hasOwnProperty(i) || !equiv(a[i], b[i]))
>> {
>> +                        return false;
>> +                    }
>> +                }
>> +            }
>> +
>> +            // Need only to verify that b's property are also a's
>> property
>> +            for (i in b) {
>> +                if (b.hasOwnProperty(i) && !a.hasOwnProperty(i)) {
>> +                    return false;
>> +                }
>> +            }
>> +
>> +            return true;
>>          }
>>
>>          if (typeof a === "function") {
>>
>> Bye, Markus
>>
>> On 22 Okt., 14:22, "Jörn Zaefferer" <[EMAIL PROTECTED]>
>> wrote:
>>
>> > I'm happy to commit whatever you guys deem useful for equiv and QUnit.
>> > A patch is perfect, that way I know that it isn't just code you were
>> > trying out.
>>
>> > Thanks
>> > Jörn
>>
>> > On Wed, Oct 22, 2008 at 2:23 PM, Philippe Rathe <[EMAIL PROTECTED]> wrote:
>>
>> > > Thanks Markus.
>> > > That was a nice optimization. All tests passed.
>> > > It will surely be patch in QUnit soon.
>>
>> > > By the way you can download the testsuites and the sources 
>> > > :http://philrathe.com/projects/equiv
>> > > Download the archive. It is always to latest.
>>
>> > > Philippe Rathé
>>
>> > > On 22-Oct-08, at 5:42 AM, markus.staab wrote:
>>
>> > >> the first loop has a problem:
>>
>> > >> it should read
>>
>> > >>            // Everything in a should be in b and equivalent and ...
>> > >>            for (var i in a) {
>> > >>               if(a.hasOwnProperty(i))
>> > >>               {
>> > >>                           if (!b.hasOwnProperty(i) || !equiv(a[i], 
>> > >> b[i]))
>> > >>                           {
>> > >>                                   return false;
>> > >>                           }
>> > >>                   }
>> > >>            }
>>
>> > >> this approach would also save the memory for the 2 property stacks you
>> > >> use in your latest solution.
>>
>> > >> On 22 Okt., 11:35, "markus.staab" <[EMAIL PROTECTED]> wrote:
>> > >>> i came up with another idea:
>>
>> > >>>             // Everything in a should be in b and equivalent and ...
>> > >>>             for (var i in a) {
>> > >>>                     if (!(a.hasOwnProperty(i) &&
>> > >>> b.hasOwnProperty(i) &&
>> > >>> equiv(a[i], b[i]))) {
>> > >>>                             return false;
>> > >>>                     }
>> > >>>             }
>>
>> > >>>             // is there any property in b left, which doesn't exist
>> > >>> in
>> > >>> a?
>> > >>>             for (var i in b) {
>> > >>>                 if (b.hasOwnProperty(i) && !a.hasOwnProperty(i)) {
>> > >>>                     return false;
>> > >>>                 }
>> > >>>             }
>>
>> > >>> maybe you can give it a try and also perform a benchmark (maybe you
>> > >>> could share your test and benchmark, so I can also test my ideas on
>> > >>> my
>> > >>> machine...)
>>
>> > >>> bye, markus
>>
>> > >>> On 22 Okt., 11:14, "markus.staab" <[EMAIL PROTECTED]> wrote:
>>
>> > >>>> hi Philippe,
>>
>> > >>>> in your new code you are doing the following:
>>
>> > >>>> 50                  // Stack all property names for a last minute
>> > >>>> check for
>> > >>>> two good reasons:
>> > >>>> 51                  // 1) To prevent failing when comparing
>> > >>>> 52                  //      a property that have an undefined value
>> > >>>> 53                  //      with a property that do not exists.
>> > >>>> 54                  // 2) To allow verifying equivalence in one
>> > >>>> way (a ->
>> > >>>> b)
>> > >>>> 55                  //      and then comparing both property names
>> > >>>> to
>> > >>>> replace
>> > >>>> 56                  //      (b -> a) processing. It's faster.
>> > >>>> 57                  var aProperties = [], bProperties = [];
>> > >>>> 58
>> > >>>> 59                  // Verify a's properties with b's properties
>> > >>>> 60                  for (i in a) {
>> > >>>> 61                      if (eq) {
>> > >>>> 62                          if (a.hasOwnProperty(i)) {
>> > >>>> 63                              aProperties.push(i);
>> > >>>> 64                              eq = equiv(a[i], b[i]);
>> > >>>> 65                          }
>> > >>>> 66                      } else {
>> > >>>> 67                          return false;
>> > >>>> 68                      }
>> > >>>> 69                  }
>> > >>>> 70
>> > >>>> 71                  // Get only b's property names
>> > >>>> 72                  if (eq) {
>> > >>>> 73                      for (i in b) {
>> > >>>> 74                          if (b.hasOwnProperty(i)) {
>> > >>>> 75                              bProperties.push(i);
>> > >>>> 76                          }
>> > >>>> 77                      }
>> > >>>> 78                  }
>> > >>>> 79
>> > >>>> 80                  // Finally, ensures also the same property
>> > >>>> names in
>> > >>>> both ways.
>> > >>>> 81                  // That will also ensures that no property with
>> > >>>> undefined value is left behind.
>> > >>>> 82                  return eq && equiv(aProperties, bProperties);
>>
>> > >>>> in this you compare the properties from a and b twice. line 64
>> > >>>> should
>> > >>>> be deleted. the properties are compared in the next recursion
>> > >>>> anyway.
>> > >>>> make the 2 "for (x in y)"-loops less complex and only collect the
>> > >>>> properties. but then it would be optimized for the "eqiv"-case.
>>
>> > >>>> On 21 Okt., 22:55, Philippe Rathe <[EMAIL PROTECTED]> wrote:
>>
>> > >>>>> Please don't use that patch because it breaks the QUnit equiv test
>> > >>>>> suites.
>> > >>>>> My explanations can be found in my previous post.
>>
>> > >>>>> For some of the patched code that can be use, some benchmark need
>> > >>>>> to
>> > >>>>> be done anyway.
>>
>> > >>>>> Thanks anyway.
>>
>> > >>>>> Philippe Rathé
>> > >>>>> On 21-Oct-08, at 2:42 PM, markus.staab wrote:
>>
>> > >>>>>> Index: testrunner.js
>> > >>>>>> =
>> > >>>>>> ==================================================================
>> > >>>>>> --- testrunner.js  (revision 5901)
>> > >>>>>> +++ testrunner.js  (working copy)
>> > >>>>>> @@ -428,8 +428,8 @@
>> > >>>>>>             if (len !== b.length) { // safe and faster
>> > >>>>>>                 return false;
>> > >>>>>>             }
>> > >>>>>> -            for (var i = 0; i < len; i++) {
>> > >>>>>> -                eq = eq && equiv(a[i], b[i]);
>> > >>>>>> +            for (var i = 0; i < len && eq; i++) {
>> > >>>>>> +                eq = equiv(a[i], b[i]);
>> > >>>>>>             }
>> > >>>>>>             return eq;
>> > >>>>>>         }
>> > >>>>>> @@ -447,15 +447,15 @@
>>
>> > >>>>>>             // Everything in a should be in b and equivalent
>> > >>>>>> and ...
>> > >>>>>>             for (var i in a) {
>> > >>>>>> -                if (a.hasOwnProperty(i)) {
>> > >>>>>> -                    eq = eq && equiv(a[i], b[i]);
>> > >>>>>> +                if (!a.hasOwnProperty(i) || !equiv(a[i], b[i])) {
>> > >>>>>> +                    return false;
>> > >>>>>>                 }
>> > >>>>>>             }
>>
>> > >>>>>>             // ... everything in b should be in a and equivalent
>> > >>>>>>             for (var i in b) {
>> > >>>>>> -                if (b.hasOwnProperty(i)) {
>> > >>>>>> -                    eq = eq && equiv(b[i], a[i]);
>> > >>>>>> +                if (!b.hasOwnProperty(i) || !equiv(b[i], a[i])) {
>> > >>>>>> +                    return false;
>> > >>>>>>                 }
>> > >>>>>>             }
>>
>> > >>>>>> On 21 Okt., 19:47, "Jörn Zaefferer"
>> > >>>>>> <[EMAIL PROTECTED]>
>> > >>>>>> wrote:
>> > >>>>>>> Could you provide these as patches against the current 
>> > >>>>>>> revision?http://jqueryjs.googlecode.com/svn/trunk/qunit/testrunner.js
>>
>> > >>>>>>> Thanks
>> > >>>>>>> Jörn
>>
>> > >>>>>>> On Tue, Oct 21, 2008 at 7:35 PM, markus.staab
>> > >>>>>>> <[EMAIL PROTECTED]> wrote:
>>
>> > >>>>>>>> even shorter
>>
>> > >>>>>>>> 52                  for (var i in a) {
>> > >>>>>>>> 53                      if (!a.hasOwnProperty(i) || !equiv(a[i],
>> > >>>>>>>> b[i])) {
>> > >>>>>>>> 54                        return false;
>>
>> ...
>>
>> Erfahren Sie mehr »
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to