diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-07-21 13:56:54 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-07-23 22:17:52 (GMT) |
commit | 1a09f345860834fb1c2005e65948fa296b201e8b (patch) | |
tree | fb25ea8a08d34fa2ca2298792ef8e559841932a7 /src/compression/dict.c | |
parent | 3e2c4306bba827d5b1d3444d5fb9a81e4b2a88bb (diff) |
Improved TNG compression speed.
Change-Id: I71c66c6b534cb402048dcd75e008d3db4bd3fb71
Diffstat (limited to 'src/compression/dict.c')
-rw-r--r-- | src/compression/dict.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/compression/dict.c b/src/compression/dict.c index 24e6ae7..fdfe7a0 100644 --- a/src/compression/dict.c +++ b/src/compression/dict.c @@ -1,7 +1,7 @@ /* This code is part of the tng compression routines. * - * Written by Daniel Spangberg - * Copyright (c) 2010, 2013, The GROMACS development team. + * Written by Daniel Spangberg and Magnus Lundborg + * Copyright (c) 2010, 2013-2014 The GROMACS development team. * * * This program is free software; you can redistribute it and/or @@ -17,6 +17,7 @@ void Ptngc_comp_canonical_dict(unsigned int *dict, int *ndict) int i; for (i=0; i<0x20004; i++) dict[i]=i; + *ndict=0x20004; } @@ -26,18 +27,19 @@ void Ptngc_comp_make_dict_hist(unsigned int *vals, int nvals, { int i; int j=0; - for (i=0; i<0x20004; i++) - hist[i]=0; - for (i=0; i<0x20004; i++) - dict[i]=i; + + memset(hist, 0, sizeof(unsigned int)*0x20004); + for (i=0; i<nvals; i++) hist[vals[i]]++; for (i=0; i<0x20004; i++) if (hist[i]!=0) { hist[j]=hist[i]; - dict[j]=dict[i]; + dict[j]=i; j++; + if(j==nvals) + break; } *ndict=j; } |