summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-04-23 18:28:33 +0200
committerTimo Weingärtner <timo@tiwe.de>2013-04-23 18:28:33 +0200
commit9d0562d22cef95b0db1af30e199a371670ca8050 (patch)
tree5312b89f87cbd28f674eb2bd46153da35e7dad28
parentfb3fe1b085b30fcc9defa8f29477226806db085b (diff)
downloadhadori-9d0562d22cef95b0db1af30e199a371670ca8050.tar.gz
remove hashing stuff
the cases in which that gave a speedup are rare to nonexistent
-rw-r--r--Makefile2
-rw-r--r--hadori.C4
-rw-r--r--inode.h27
3 files changed, 3 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index a55a9dd..faad8fa 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with hadori. If not, see <http://www.gnu.org/licenses/>.
-LDFLAGS+=-lz -lboost_program_options
+LDFLAGS+=-lboost_program_options
CXXFLAGS?=-O2 -Wall
CXXFLAGS+=-std=c++0x
CPPFLAGS+=-D_FILE_OFFSET_BITS=64
diff --git a/hadori.C b/hadori.C
index c2d24a9..b5e1a57 100644
--- a/hadori.C
+++ b/hadori.C
@@ -105,9 +105,6 @@ void handle_file(std::string const & path, struct stat const & s) {
if (not config.count("no-time"))
if (candidate.stat.st_mtime != s.st_mtime)
continue;
- if (config.count("hash"))
- if (candidate.get_adler() != f.get_adler())
- continue;
if (!compare(candidate, f))
continue;
verbose << "linking " << candidate << " to " << path << std::endl;
@@ -190,7 +187,6 @@ int main (int const argc, char ** argv) {
("help,h", "print this help message")
("version,V", "print version information")
("no-time,t", "ignore mtime")
- ("hash", "use adler32 hash to speed up comparing many files with same size and mostly identical content")
("dry-run,n", "don't change anything, implies --verbose")
("verbose,v", "show which files get linked")
("debug,d", "show files being examined")
diff --git a/inode.h b/inode.h
index 26db923..5c74a79 100644
--- a/inode.h
+++ b/inode.h
@@ -25,39 +25,16 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include <zlib.h>
-
-class inode {
-public:
+struct inode {
std::string const filename;
struct stat const stat;
-protected:
- uLong mutable adler;
-
-public:
inode (std::string const &, struct stat const);
- uLong get_adler () const;
-
friend bool compare (inode const &, inode const &);
friend std::ostream& operator<< (std::ostream&, inode const &);
};
-inline inode::inode (std::string const & __filename, struct stat const __stat) : filename(__filename), stat(__stat), adler(-1) {
-}
-
-inline uLong inode::get_adler () const {
- if (adler == uLong(-1)) {
- char buffer[1 << 14];
- std::ifstream f(filename.c_str());
-
- adler = adler32(0L, Z_NULL, 0);
- while (not f.eof()) {
- f.read(buffer, sizeof(buffer));
- adler = adler32(adler, (Bytef *) buffer, f.gcount());
- }
- }
- return adler;
+inline inode::inode (std::string const & __filename, struct stat const __stat) : filename(__filename), stat(__stat) {
}
inline bool compare (inode const & l, inode const & r) {