RE: [ogfs-dev]Tiny patch for replace bubble sort with shell sort.
Thanks a lot.
Regards,
Stan
On Fri, 30 May 2003, Cahill, Ben M wrote:
> Hi Stanley,
>
> I'll add you onto developers list next week.
>
> Then you can check in this patch yourself.
>
> Thanks!
>
> -- Ben --
>
> > -----Original Message-----
> > From: Stanley Wang [mailto:stanley.wang@linux.co.intel.com]
> > Sent: Friday, May 30, 2003 6:03 AM
> > To: OpenGFS-Dev
> > Subject: [ogfs-dev]Tiny patch for replace bubble sort with shell sort.
> >
> >
> > Hi, folks
> > Following is a tiny patch that eliminate the bubble sort in
> > fs/fs.c and fs/blklist.c
> > I've test it against the lastest cvs source.
> > Any comments?
> >
> > Regards,
> > Stan
> >
> > Index: src/fs/blklist.c
> > ===================================================================
> > RCS file: /cvsroot/opengfs/opengfs/src/fs/blklist.c,v
> > retrieving revision 1.29
> > diff -r1.29 blklist.c
> > 1944a1945,1955
> > > * ogfs_rlist_compar - compare address. Used by ogfs_rlist_sort.
> > > * @a: resource group a
> > > * @b: resource group b
> > > * Return : 1 a > b -1 a < b
> > > */
> > > int ogfs_rlist_compar(const void *a, const void *b)
> > > {
> > > return ((*(ogfs_rgrpd_t **)a)->rd_ri.ri_addr >
> > (*(ogfs_rgrpd_t **)b)->rd_ri.ri_addr) ? 1:-1;
> > > }
> > >
> > > /**
> > 1948d1958
> > < * Dammit!!! Get a better sorting algorithm.
> > 1950d1959
> > <
> > 1954c1963
> > < ogfs_rgrpd_t **list = rlist->rl_list, *tmp;
> > ---
> > > ogfs_rgrpd_t **list = rlist->rl_list;
> > 1956,1957d1964
> > < unsigned int x;
> > < int changed;
> > 1965,1976c1972
> > < do {
> > < changed = FALSE;
> > < for (x = 1; x < rgrps; x++) {
> > < if (list[x-1]->rd_ri.ri_addr
> > >list[x]->rd_ri.ri_addr) {
> > < tmp = list[x - 1];
> > < list[x - 1] = list[x];
> > < list[x] = tmp;
> > < changed = TRUE;
> > < }
> > < }
> > < } while (changed);
> > <
> > ---
> > > ogfs_sort((void *)list, (rgrps - 1), sizeof(*list),
> > ogfs_rlist_compar);
> > Index: src/fs/fs.c
> > ===================================================================
> > RCS file: /cvsroot/opengfs/opengfs/src/fs/fs.c,v
> > retrieving revision 1.8
> > diff -r1.8 fs.c
> > 132c132
> > < * ogfs_sort - Sort base array using bubble sort algorithm
> > ---
> > > * ogfs_sort - Sort base array using shell sort algorithm
> > 139c139
> > < * the bubble sort algorithm
> > ---
> > > * the shell sort algorithm
> > 147,149c147,149
> > < register unsigned int i;
> > < unsigned int last = num_elem;
> > < register unsigned int sorted = FALSE;
> > ---
> > > int i, j, k, h;
> > > int cols[16] = {1391376, 463792, 198768, 86961, 33936,
> > 13776, 4592,
> > > 1968, 861, 336, 112, 48, 21, 7, 3, 1};
> > 153,162c153,159
> > < while (!sorted) {
> > < sorted = TRUE;
> > <
> > < for (i = 0; i < last; i++) {
> > < char *a = pbase + size * i;
> > < char *b = pbase + (size * i) + size;
> > <
> > < if ((*compar) ((void *) a, (void *) b) > 0) {
> > < SWAP(a, b, size);
> > < sorted = FALSE;
> > ---
> > > for (k=0; k<16; k++) {
> > > h=cols[k];
> > > for (i=h; i<=num_elem; i++) {
> > > j=i;
> > > while (j>=h && (*compar)((void
> > *)(pbase+size*(j-h)), (void *)(pbase+size*j))>0) {
> > >
> > SWAP(pbase+size*j,pbase+size*(j-h),size);
> > > j=j-h;
> > 165,166d161
> > <
> > < last = last - 1;
> > 168d162
> > <
> >
> >
> >
> > --
> > Opinions expressed are those of the author and do not represent Intel
> > Corporation
> >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: eBay
> > Get office equipment for less on eBay!
> > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> > _______________________________________________
> > Opengfs-devel mailing list
> > Opengfs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/opengfs-devel
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: eBay
> Get office equipment for less on eBay!
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> Opengfs-devel mailing list
> Opengfs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opengfs-devel
>
--
Opinions expressed are those of the author and do not represent Intel
Corporation
-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Opengfs-devel mailing list
Opengfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opengfs-devel
[Kernel]
[Security]
[Bugtraq]
[Photo]
[Yosemite]
[MIPS Linux]
[ARM Linux]
[Linux Clusters]
[Linux RAID]
[Yosemite Hiking]
[Linux Resources]