##// END OF EJS Templates
dirstate.read: make 15% faster....
Vadim Gelfer -
r2427:150cde10 default
parent child Browse files
Show More
@@ -155,31 +155,41 b' class dirstate(object):'
155 if self.map is None:
155 if self.map is None:
156 self.read()
156 self.read()
157
157
158 def read(self):
158 def parse(self, st):
159 self.map = {}
160 self.pl = [nullid, nullid]
161 try:
162 st = self.opener("dirstate").read()
163 if not st: return
164 except: return
165
166 self.pl = [st[:20], st[20: 40]]
159 self.pl = [st[:20], st[20: 40]]
167
160
161 # deref fields so they will be local in loop
162 map = self.map
163 copies = self.copies
164 format = self.format
165 unpack = struct.unpack
166
168 pos = 40
167 pos = 40
169 e_size = struct.calcsize(self.format)
168 e_size = struct.calcsize(format)
169
170 while pos < len(st):
170 while pos < len(st):
171 newpos = pos + e_size
171 newpos = pos + e_size
172 e = struct.unpack(self.format, st[pos:newpos])
172 e = unpack(format, st[pos:newpos])
173 l = e[4]
173 l = e[4]
174 pos = newpos
174 pos = newpos
175 newpos = pos + l
175 newpos = pos + l
176 f = st[pos:newpos]
176 f = st[pos:newpos]
177 if '\0' in f:
177 if '\0' in f:
178 f, c = f.split('\0')
178 f, c = f.split('\0')
179 self.copies[f] = c
179 copies[f] = c
180 self.map[f] = e[:4]
180 map[f] = e[:4]
181 pos = newpos
181 pos = newpos
182
182
183 def read(self):
184 self.map = {}
185 self.pl = [nullid, nullid]
186 try:
187 st = self.opener("dirstate").read()
188 if st:
189 self.parse(st)
190 except IOError, err:
191 if err.errno != errno.ENOENT: raise
192
183 def copy(self, source, dest):
193 def copy(self, source, dest):
184 self.lazyread()
194 self.lazyread()
185 self.markdirty()
195 self.markdirty()
General Comments 0
You need to be logged in to leave comments. Login now