##// END OF EJS Templates
dirstate: remove excess attribute lookups for dirstate.status (issue5714)...
Durham Goode -
r34936:ffeea240 stable
parent child Browse files
Show More
@@ -1053,6 +1053,9 b' class dirstate(object):'
1053 removed, deleted, clean = [], [], []
1053 removed, deleted, clean = [], [], []
1054
1054
1055 dmap = self._map
1055 dmap = self._map
1056 dmap.preload()
1057 dcontains = dmap.__contains__
1058 dget = dmap.__getitem__
1056 ladd = lookup.append # aka "unsure"
1059 ladd = lookup.append # aka "unsure"
1057 madd = modified.append
1060 madd = modified.append
1058 aadd = added.append
1061 aadd = added.append
@@ -1074,7 +1077,7 b' class dirstate(object):'
1074 full = listclean or match.traversedir is not None
1077 full = listclean or match.traversedir is not None
1075 for fn, st in self.walk(match, subrepos, listunknown, listignored,
1078 for fn, st in self.walk(match, subrepos, listunknown, listignored,
1076 full=full).iteritems():
1079 full=full).iteritems():
1077 if fn not in dmap:
1080 if not dcontains(fn):
1078 if (listignored or mexact(fn)) and dirignore(fn):
1081 if (listignored or mexact(fn)) and dirignore(fn):
1079 if listignored:
1082 if listignored:
1080 iadd(fn)
1083 iadd(fn)
@@ -1089,7 +1092,7 b' class dirstate(object):'
1089 # a list, but falls back to creating a full-fledged iterator in
1092 # a list, but falls back to creating a full-fledged iterator in
1090 # general. That is much slower than simply accessing and storing the
1093 # general. That is much slower than simply accessing and storing the
1091 # tuple members one by one.
1094 # tuple members one by one.
1092 t = dmap[fn]
1095 t = dget(fn)
1093 state = t[0]
1096 state = t[0]
1094 mode = t[1]
1097 mode = t[1]
1095 size = t[2]
1098 size = t[2]
@@ -1216,8 +1219,8 b' class dirstatemap(object):'
1216 return self.copymap
1219 return self.copymap
1217
1220
1218 def clear(self):
1221 def clear(self):
1219 self._map = {}
1222 self._map.clear()
1220 self.copymap = {}
1223 self.copymap.clear()
1221 self.setparents(nullid, nullid)
1224 self.setparents(nullid, nullid)
1222
1225
1223 def iteritems(self):
1226 def iteritems(self):
@@ -1247,6 +1250,10 b' class dirstatemap(object):'
1247 def keys(self):
1250 def keys(self):
1248 return self._map.keys()
1251 return self._map.keys()
1249
1252
1253 def preload(self):
1254 """Loads the underlying data, if it's not already loaded"""
1255 self._map
1256
1250 def nonnormalentries(self):
1257 def nonnormalentries(self):
1251 '''Compute the nonnormal dirstate entries from the dmap'''
1258 '''Compute the nonnormal dirstate entries from the dmap'''
1252 try:
1259 try:
@@ -1373,6 +1380,13 b' class dirstatemap(object):'
1373 if not self._dirtyparents:
1380 if not self._dirtyparents:
1374 self.setparents(*p)
1381 self.setparents(*p)
1375
1382
1383 # Avoid excess attribute lookups by fast pathing certain checks
1384 self.__contains__ = self._map.__contains__
1385 self.__getitem__ = self._map.__getitem__
1386 self.__setitem__ = self._map.__setitem__
1387 self.__delitem__ = self._map.__delitem__
1388 self.get = self._map.get
1389
1376 def write(self, st, now):
1390 def write(self, st, now):
1377 st.write(parsers.pack_dirstate(self._map, self.copymap,
1391 st.write(parsers.pack_dirstate(self._map, self.copymap,
1378 self.parents(), now))
1392 self.parents(), now))
General Comments 0
You need to be logged in to leave comments. Login now