##// 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 1053 removed, deleted, clean = [], [], []
1054 1054
1055 1055 dmap = self._map
1056 dmap.preload()
1057 dcontains = dmap.__contains__
1058 dget = dmap.__getitem__
1056 1059 ladd = lookup.append # aka "unsure"
1057 1060 madd = modified.append
1058 1061 aadd = added.append
@@ -1074,7 +1077,7 b' class dirstate(object):'
1074 1077 full = listclean or match.traversedir is not None
1075 1078 for fn, st in self.walk(match, subrepos, listunknown, listignored,
1076 1079 full=full).iteritems():
1077 if fn not in dmap:
1080 if not dcontains(fn):
1078 1081 if (listignored or mexact(fn)) and dirignore(fn):
1079 1082 if listignored:
1080 1083 iadd(fn)
@@ -1089,7 +1092,7 b' class dirstate(object):'
1089 1092 # a list, but falls back to creating a full-fledged iterator in
1090 1093 # general. That is much slower than simply accessing and storing the
1091 1094 # tuple members one by one.
1092 t = dmap[fn]
1095 t = dget(fn)
1093 1096 state = t[0]
1094 1097 mode = t[1]
1095 1098 size = t[2]
@@ -1216,8 +1219,8 b' class dirstatemap(object):'
1216 1219 return self.copymap
1217 1220
1218 1221 def clear(self):
1219 self._map = {}
1220 self.copymap = {}
1222 self._map.clear()
1223 self.copymap.clear()
1221 1224 self.setparents(nullid, nullid)
1222 1225
1223 1226 def iteritems(self):
@@ -1247,6 +1250,10 b' class dirstatemap(object):'
1247 1250 def keys(self):
1248 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 1257 def nonnormalentries(self):
1251 1258 '''Compute the nonnormal dirstate entries from the dmap'''
1252 1259 try:
@@ -1373,6 +1380,13 b' class dirstatemap(object):'
1373 1380 if not self._dirtyparents:
1374 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 1390 def write(self, st, now):
1377 1391 st.write(parsers.pack_dirstate(self._map, self.copymap,
1378 1392 self.parents(), now))
General Comments 0
You need to be logged in to leave comments. Login now