Little curiosity about getAllPlayersArray() and similars

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Ekkuzu
Posts: 4
Joined: Thu Sep 16, 2010 11:13 am

Little curiosity about getAllPlayersArray() and similars

Post by Ekkuzu »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision 8406:
L2JDP Revision 4952:

Ok, I've been aplying some changes on my local project, and I've saw a thing that I don't understood at all when changing some foreach loops from L2World instance. (.getAllPlayers().values() if I'm correct, to put an example)

Code: Select all

for (L2PcInstance cha : L2World.getInstance().getAllPlayersArray())
and

Code: Select all

private void disconnectAllCharacters(){    L2World.getInstance().getAllPlayers().safeForEachValue(new disconnectAllCharacters());}
Where "new disconnectAllCharacters()" it's a class who implements TObjectProcedure and has the old loop body.

The point is: why some have the first manner and some the second? Maybe that private class that implements TObjectProcedure is faster or what? I know less lines do not means always haste, but IMO it's make things more complex, using a separate method + class rather than a simple array.

Thanks and let's see if someone knows why. Cheers.
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: Little curiosity about getAllPlayersArray() and similars

Post by tukune »

readLock/writeLock
Post Reply