Merge lp://qastaging/~andersk/sreadahead/qsort into lp://qastaging/~ubuntu-core-dev/sreadahead/ubuntu

Proposed by Anders Kaseorg
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~andersk/sreadahead/qsort
Merge into: lp://qastaging/~ubuntu-core-dev/sreadahead/ubuntu
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~andersk/sreadahead/qsort
Reviewer Review Type Date Requested Status
Scott James Remnant (Canonical) Pending
Review via email: mp+12140@code.qastaging.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2009-09-15 02:39:28 +0000
3+++ debian/changelog 2009-09-20 17:35:00 +0000
4@@ -1,3 +1,10 @@
5+sreadahead (1.0-4) karmic; urgency=low
6+
7+ * Replace custom bubble sort with qsort(), to avoid using 100% CPU
8+ for a long time after boot. (LP: #421116)
9+
10+ -- Anders Kaseorg <andersk@mit.edu> Sun, 20 Sep 2009 13:31:45 -0400
11+
12 sreadahead (1.0-3) karmic; urgency=low
13
14 FFE LP: #427356.
15
16=== modified file 'sreadahead.c'
17--- sreadahead.c 2009-07-20 16:28:56 +0000
18+++ sreadahead.c 2009-09-20 17:35:00 +0000
19@@ -187,26 +187,21 @@
20 return NULL;
21 }
22
23+static int compare_ras_by_name(const void *memb1, const void *memb2)
24+{
25+ struct ra_struct *const *ra1 = memb1, *const *ra2 = memb2;
26+ int c = strcmp((*ra1)->filename, (*ra2)->filename);
27+
28+ if (c != 0)
29+ return c;
30+
31+ /* Leave equal filenames in the original order. */
32+ return (*ra1)->number - (*ra2)->number;
33+}
34+
35 static void sort_ra_by_name(void)
36 {
37- int delta = 1;
38-
39- while (delta > 0) {
40- int i;
41- delta = 0;
42- for (i = 0; i < racount - 1; i++) {
43- int c;
44-
45- c = strcmp(ra[i]->filename, ra[i+1]->filename);
46- if (c > 0) {
47- struct ra_struct *tmp;
48- tmp = ra[i];
49- ra[i] = ra[i+1];
50- ra[i+1] = tmp;
51- delta++;
52- }
53- }
54- }
55+ qsort(ra, racount, sizeof(*ra), compare_ras_by_name);
56 }
57
58 static void remove_dupes(void)

Subscribers

People subscribed via source and target branches