1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
diff -ru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc
--- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-24 09:53:27.000000000 +0000
+++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-24 09:42:05.000000000 +0000
@@ -45,7 +45,7 @@
const char *Stop;
if (Section.Find(Tag,Start,Stop) == false)
return 0;
- return WriteString(Start,Stop - Start);
+ return WriteString(srkString(Start,Stop - Start));
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
diff -ru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc
--- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2010-02-24 09:53:27.000000000 +0000
+++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2010-02-24 09:51:06.000000000 +0000
@@ -680,21 +680,38 @@
unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
unsigned int Size)
{
+ return WriteString(srkString(S, Size), srkSeriouslyUnique);
+}
+
+unsigned long pkgCacheGenerator::WriteString(const srkString &S,
+ enum srkLevel level)
+{
+ if (level == srkRunOfTheMillNormal)
+ return Map.WriteString(S.Start,S.Size);
+
/* We use a very small transient hash table here, this speeds up generation
by a fair amount on slower machines */
- pkgCache::StringItem *&Bucket = UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)];
+ pkgCache::StringItem *&Bucket(level == srkReasonablySpecial ? SpecHash[(S[0]*5 + S[1]) % _count(SpecHash)] : UniqHash[(S[0]*5 + S[1]) % _count(UniqHash)]);
if (Bucket != 0 &&
- stringcmp(S,S+Size,Cache.StrP + Bucket->String) == 0)
+ stringcmp(S,Cache.StrP + Bucket->String) == 0)
return Bucket->String;
+ pkgCache::StringItem *I;
+ map_ptrloc *Last;
+
+ if (level != srkSeriouslyUnique) {
+ I = NULL;
+ Last = NULL;
+ } else {
+
// Search for an insertion point
- pkgCache::StringItem *I = Cache.StringItemP + Cache.HeaderP->StringList;
+ I = Cache.StringItemP + Cache.HeaderP->StringList;
int Res = 1;
- map_ptrloc *Last = &Cache.HeaderP->StringList;
+ Last = &Cache.HeaderP->StringList;
for (; I != Cache.StringItemP; Last = &I->NextItem,
I = Cache.StringItemP + I->NextItem)
{
- Res = stringcmp(S,S+Size,Cache.StrP + I->String);
+ Res = stringcmp(S,Cache.StrP + I->String);
if (Res >= 0)
break;
}
@@ -705,6 +722,8 @@
Bucket = I;
return I->String;
}
+
+ }
// Get a structure
unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
@@ -714,8 +733,9 @@
// Fill in the structure
pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
ItemP->NextItem = I - Cache.StringItemP;
- *Last = Item;
- ItemP->String = Map.WriteString(S,Size);
+ if (Last != NULL)
+ *Last = Item;
+ ItemP->String = Map.WriteString(S.Start,S.Size);
if (ItemP->String == 0)
return 0;
diff -ru apt-0.7.25.3/apt-pkg/pkgcachegen.h apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h
--- apt-0.7.25.3/apt-pkg/pkgcachegen.h 2010-02-24 09:53:27.000000000 +0000
+++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h 2010-02-24 09:50:07.000000000 +0000
@@ -32,13 +32,16 @@
{
private:
- pkgCache::StringItem *UniqHash[26];
+ pkgCache::StringItem *UniqHash[24];
+ pkgCache::StringItem *SpecHash[2];
public:
class ListParser;
friend class ListParser;
+ enum srkLevel { srkRunOfTheMillNormal, srkReasonablySpecial, srkSeriouslyUnique };
+
protected:
DynamicMMap ⤅
@@ -63,6 +66,7 @@
unsigned long WriteUniqString(const char *S,unsigned int Size);
inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
+ unsigned long WriteString(const srkString &S, enum srkLevel level);
void DropProgress() {Progress = 0;};
bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index,
@@ -98,7 +102,7 @@
inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
- inline unsigned long WriteString(const srkString &S) {return Owner->Map.WriteString(S.Start,S.Size);};
+ inline unsigned long WriteString(const srkString &S) {return Owner->WriteString(S, srkReasonablySpecial);};
bool NewDepends(pkgCache::VerIterator Ver,const string &Package,
const string &Version,unsigned int Op,
unsigned int Type);
|