Avoid creating temporary lists where possible
This commit is contained in:
parent
67f3d56846
commit
8ba96f9b13
@ -1573,10 +1573,7 @@ class MCInfdevOldLevel(MCLevel):
|
||||
|
||||
playerFilePath = os.path.join(self.worldDir, "players")
|
||||
if os.path.exists(playerFilePath):
|
||||
playerDats = os.listdir(playerFilePath);
|
||||
playerDats = filter(lambda x:x.endswith(".dat"), playerDats)
|
||||
players = map(lambda x:x[:-4], playerDats);
|
||||
self.players = players
|
||||
self.players = [x[:-4] for x in os.listdir(playerFilePath) if x.endswith(".dat")]
|
||||
|
||||
self.preloadChunkPaths();
|
||||
|
||||
|
4
nbt.py
4
nbt.py
@ -233,7 +233,7 @@ class TAG_Compound(TAG_Value, collections.MutableMapping):
|
||||
|
||||
|
||||
def nbt_length(self):
|
||||
return sum(map(lambda x:(x.nbt_length()+len(x.name)+3), self.value))+1;
|
||||
return sum(x.nbt_length() + len(x.name) + 3 for x in self.value) + 1;
|
||||
|
||||
def write_value(self, buf):
|
||||
for i in self.value:
|
||||
@ -347,7 +347,7 @@ class TAG_List(TAG_Value, collections.MutableSequence):
|
||||
self.list.insert(i, v);
|
||||
|
||||
def nbt_length(self):
|
||||
return 5 + sum(map(lambda x:x.nbt_length(), self.list));
|
||||
return 5 + sum(x.nbt_length() for x in self.list)
|
||||
|
||||
def write_value(self, buf):
|
||||
buf.write(struct.pack(TAGfmt, self.list_type))
|
||||
|
Reference in New Issue
Block a user