Avoid creating temporary lists where possible
This commit is contained in:
parent
d85ffc1b8f
commit
b766af613c
@ -1564,10 +1564,7 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
|
|
||||||
playerFilePath = os.path.join(self.worldDir, "players")
|
playerFilePath = os.path.join(self.worldDir, "players")
|
||||||
if os.path.exists(playerFilePath):
|
if os.path.exists(playerFilePath):
|
||||||
playerDats = os.listdir(playerFilePath);
|
self.players = [x[:-4] for x in os.listdir(playerFilePath) if x.endswith(".dat")]
|
||||||
playerDats = filter(lambda x:x.endswith(".dat"), playerDats)
|
|
||||||
players = map(lambda x:x[:-4], playerDats);
|
|
||||||
self.players = players
|
|
||||||
|
|
||||||
self.preloadChunkPaths();
|
self.preloadChunkPaths();
|
||||||
|
|
||||||
|
4
nbt.py
4
nbt.py
@ -238,7 +238,7 @@ class TAG_Compound(TAG_Value, collections.MutableMapping):
|
|||||||
|
|
||||||
|
|
||||||
def nbt_length(self):
|
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):
|
def write_value(self, buf):
|
||||||
for i in self.value:
|
for i in self.value:
|
||||||
@ -352,7 +352,7 @@ class TAG_List(TAG_Value, collections.MutableSequence):
|
|||||||
self.list.insert(i, v);
|
self.list.insert(i, v);
|
||||||
|
|
||||||
def nbt_length(self):
|
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):
|
def write_value(self, buf):
|
||||||
buf.write(struct.pack(TAGfmt, self.list_type))
|
buf.write(struct.pack(TAGfmt, self.list_type))
|
||||||
|
Reference in New Issue
Block a user