Last active
December 28, 2015 01:39
-
-
Save naftaliharris/7422389 to your computer and use it in GitHub Desktop.
Revisions
-
naftaliharris revised this gist
Nov 14, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ int partition(LSObject *ls, int left, int right) { for (int i = left + 1; i < right; i++) { __builtin_prefetch(ob_item[i+3]); /* This is the added line */ IF_LESS_THAN(ob_item[i], pivot) { last_less++; SWAP(i, last_less); } -
naftaliharris revised this gist
Nov 14, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ /* Modified slightly from https://github.com/naftaliharris/lazysort */ int partition(LSObject *ls, int left, int right) { PyObject **ob_item = ls->xs->ob_item; /* The array to be sorted */ int piv_idx = pick_pivot(ls, left, right); PyObject *pivot = ob_item[piv_idx]; -
naftaliharris renamed this gist
Nov 14, 2013 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,16 @@ /* Modified slightly from https://github.com/naftaliharris/lazysort */ int partition(LSObject *ls, int left, int right) { PyObject **ob_item = ls->xs->ob_item; int piv_idx = pick_pivot(ls, left, right); PyObject *pivot = ob_item[piv_idx]; SWAP(left, piv_idx); int last_less = left; /* Invariant: last_less and everything to its left is less than * pivot or the pivot itself */ for (int i = left + 1; i < right; i++) { __builtin_prefetch(ob_item[i+3]); /* This is the added line */ IFLT(ob_item[i], pivot) { last_less++; -
naftaliharris revised this gist
Nov 14, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ /* Modified slightly from https://github.com/naftaliharris/lazysort */ static Py_ssize_t partition(LSObject *ls, Py_ssize_t left, Py_ssize_t right) { -
naftaliharris revised this gist
Nov 14, 2013 . 1 changed file with 2 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,25 +2,16 @@ static Py_ssize_t partition(LSObject *ls, Py_ssize_t left, Py_ssize_t right) { PyObject **ob_item = ls->xs->ob_item; Py_ssize_t piv_idx = pick_pivot(ls, left, right); PyObject *pivot = ob_item[piv_idx]; SWAP(left, piv_idx); Py_ssize_t last_less = left; /* Invariant: last_less and everything to its left is less than * pivot or the pivot itself */ for (Py_ssize_t i = left + 1; i < right; i++) { __builtin_prefetch(ob_item[i+3]); /* This is the added line */ IFLT(ob_item[i], pivot) { last_less++; @@ -30,7 +21,4 @@ partition(LSObject *ls, Py_ssize_t left, Py_ssize_t right) SWAP(left, last_less); return last_less; } -
naftaliharris created this gist
Nov 11, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ static Py_ssize_t partition(LSObject *ls, Py_ssize_t left, Py_ssize_t right) { PyObject **ob_item = ls->xs->ob_item; PyObject *tmp; /* Used by SWAP macro */ PyObject *pivot; int ltflag; Py_ssize_t piv_idx = pick_pivot(ls, left, right); if (piv_idx < 0) { return -1; } pivot = ob_item[piv_idx]; SWAP(left, piv_idx); Py_ssize_t last_less = left; /* Invariant: last_less and everything to its left is less than * pivot or the pivot itself */ Py_ssize_t i; for (i = left + 1; i < right; i++) { __builtin_prefetch(ob_item[i+3]); /* This is the added line */ IFLT(ob_item[i], pivot) { last_less++; SWAP(i, last_less); } } SWAP(left, last_less); return last_less; fail: /* From IFLT macro */ return -1; }