[Debtags-commits] [svn] r1574 - in tagcoll/trunk: . tagcoll

Enrico Zini enrico at costa.debian.org
Mon Feb 13 15:35:05 UTC 2006


Author: enrico
Date: Mon Feb 13 15:35:03 2006
New Revision: 1574

Modified:
   tagcoll/trunk/   (props changed)
   tagcoll/trunk/tagcoll/Makefile.am
   tagcoll/trunk/tagcoll/StringIndex.cc
   tagcoll/trunk/tagcoll/StringIndex.h
Log:
 r7281 at viaza:  enrico | 2006-02-13 12:49:36 +0100
 Use first offset to compute number of items instead of storing size at the end


Modified: tagcoll/trunk/tagcoll/Makefile.am
==============================================================================
--- tagcoll/trunk/tagcoll/Makefile.am	(original)
+++ tagcoll/trunk/tagcoll/Makefile.am	Mon Feb 13 15:35:03 2006
@@ -39,6 +39,7 @@
 		TDBDiskIndex.cc \
 		TDBReadonlyDiskIndex.h \
 		\
+		MMapIndex.h \
 		IntIndex.h \
 		StringIndex.h \
 		IntDiskIndex.h \
@@ -81,6 +82,7 @@
 		TDBDiskIndex.cc \
 		TDBReadonlyDiskIndex.cc \
 		\
+		MMapIndex.cc \
 		IntIndex.cc \
 		StringIndex.cc \
 		IntDiskIndex.cc \

Modified: tagcoll/trunk/tagcoll/StringIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/StringIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/StringIndex.cc	Mon Feb 13 15:35:03 2006
@@ -92,7 +92,7 @@
 		bufsize += i->size() + 1;
 
 	// Then the int with the number of items
-	return bufsize + sizeof(int);
+	return bufsize;
 }
 
 void StringIndexer::encode(char* buf) const
@@ -105,7 +105,6 @@
 		memcpy(buf + pos, i->c_str(), i->size() + 1);
 		pos += i->size() + 1;
 	}
-	*(int*)(buf + pos) = size();
 }
 
 void StringIndexer::write(const std::string& filename)

Modified: tagcoll/trunk/tagcoll/StringIndex.h
==============================================================================
--- tagcoll/trunk/tagcoll/StringIndex.h	(original)
+++ tagcoll/trunk/tagcoll/StringIndex.h	Mon Feb 13 15:35:03 2006
@@ -60,9 +60,9 @@
 	virtual std::string operator()(const int& item) const { return data(item); }
 	virtual int operator()(const std::string& item) const { return data(item.c_str()); }
 
-	const char* data(int val) const { return m_buf + offset(val); }
+	const char* data(int val) const { return (val >= 0 && val < size()) ? m_buf + offset(val) : 0; }
 	int data(const char* str) const;
-	unsigned int size() const { return *(unsigned int*)(m_buf + m_size - sizeof(int)); }
+	unsigned int size() const { return *(unsigned int*)m_buf / sizeof(int); }
 };
 
 /**



More information about the Debtags-commits mailing list