mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Merge m-c to m-i
This commit is contained in:
commit
71a9b37026
@ -6,12 +6,13 @@
|
||||
#ifndef mozilla_dom_Touch_h
|
||||
#define mozilla_dom_Touch_h
|
||||
|
||||
#include "nsDOMUIEvent.h"
|
||||
#include "nsIDOMTouchEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -104,10 +104,10 @@ void NS_QuickSort (
|
||||
)
|
||||
{
|
||||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
int d, r, swaptype, swap_cnt;
|
||||
int d, r, swaptype;
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
swap_cnt = 0;
|
||||
/* Use insertion sort when input is small */
|
||||
if (n < 7) {
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
@ -115,6 +115,7 @@ loop: SWAPINIT(a, es);
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
/* Choose pivot */
|
||||
pm = (char *)a + (n / 2) * es;
|
||||
if (n > 7) {
|
||||
pl = (char *)a;
|
||||
@ -131,10 +132,16 @@ loop: SWAPINIT(a, es);
|
||||
pa = pb = (char *)a + es;
|
||||
|
||||
pc = pd = (char *)a + (n - 1) * es;
|
||||
/* loop invariants:
|
||||
* [a, pa) = pivot
|
||||
* [pa, pb) < pivot
|
||||
* [pb, pc + es) unprocessed
|
||||
* [pc + es, pd + es) > pivot
|
||||
* [pd + es, pn) = pivot
|
||||
*/
|
||||
for (;;) {
|
||||
while (pb <= pc && (r = cmp(pb, a, data)) <= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pa, pb);
|
||||
pa += es;
|
||||
}
|
||||
@ -142,7 +149,6 @@ loop: SWAPINIT(a, es);
|
||||
}
|
||||
while (pb <= pc && (r = cmp(pc, a, data)) >= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pc, pd);
|
||||
pd -= es;
|
||||
}
|
||||
@ -151,23 +157,16 @@ loop: SWAPINIT(a, es);
|
||||
if (pb > pc)
|
||||
break;
|
||||
swap(pb, pc);
|
||||
swap_cnt = 1;
|
||||
pb += es;
|
||||
pc -= es;
|
||||
}
|
||||
if (swap_cnt == 0) { /* Switch to insertion sort */
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
pl -= es)
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Move pivot values */
|
||||
pn = (char *)a + n * es;
|
||||
r = XPCOM_MIN(pa - (char *)a, pb - pa);
|
||||
vecswap(a, pb - r, r);
|
||||
r = XPCOM_MIN<size_t>(pd - pc, pn - pd - es);
|
||||
vecswap(pb, pn - r, r);
|
||||
/* Recursively process partitioned items */
|
||||
if ((r = pb - pa) > (int)es)
|
||||
NS_QuickSort(a, r / es, es, cmp, data);
|
||||
if ((r = pd - pc) > (int)es) {
|
||||
|
Loading…
Reference in New Issue
Block a user