Jump to content

Recommended Posts

Posted (edited)

i think can be done with many ways:

_list.remove(_list.indexOf(itemId));
_list.remove(Integer.valueOf(ItemId));
_list.remove(new Integer(itemId));

But the critical its to find the best performance.

Edited by StinkyMadness
Posted
15 minutes ago, Rootware said:

@Tryskell my example works correct. I get index first and after remove object from ArrayList by him index. What's wrong? All follows Eclipse documentation.

 

Until JIT does its work and saves the day, it's (probably) costier.

Posted
5 minutes ago, StinkyMadness said:

i think can be done with many ways:


_list.remove(_list.indexOf(itemId));
_list.remove(Integer.valueOf(ItemId));
_list.remove(new Integer(itemId));

But the critical its to find the best performance.

 

In your case not matter "best way", because too small list for feeling difference. Less few billions object in list pointless for catching performance.

Posted (edited)
19 minutes ago, Rootware said:

 

In your case not matter "best way", because too small list for feeling difference. Less few billions object in list pointless for catching performance.


Yes but is one list for each player... if all use it you better find best performance.
In other way already work with (Integer itemId)

Edited by StinkyMadness
Posted
10 minutes ago, Rootware said:

 

In your case not matter "best way", because too small list for feeling difference. Less few billions object in list pointless for catching performance.

 

remove(Integer.valueOf(

is the regular writing style, over L2J and aCis. End of story.

Posted (edited)
12 hours ago, StinkyMadness said:


Yes but is one list for each player... if all use it you better find best performance.
In other way already work with (Integer itemId)

 

If you cares about player instance, as multiplier can change performance, then cares about cleanup any customs from any this instance. By the way, everyone player's instance it's another thread and not matter how many time will be done list's operation. In your case this difference less 0,00001 second.

 

The general story line was in style of coding. :aproove-smile:

Edited by Rootware
  • Thanks 1
Posted
1 hour ago, Rootware said:

 

If you cares about player instance, as multiplier can change performance, then cares about cleanup any customs from any this instance. By the way, everyone player's instance it's another thread and not matter how many time will be done list's operation. In your case this difference less 0,00001 second.

 

The general story line was in style of coding. :aproove-smile:


i know player's instance its already kinda mess xD i'm just telling that there are 3 or more ways that are doing the same job.. i care to learn.. the best performance.. not only for this case...

Posted

I always felt like things like this have more of a place in the CommunityBoard, instead of the NpcHtml. You have more space and to add more things. Also previous/next pagination can get hectic without numbered pagination so I would add that.

 

In terms of the code the following can be optimized:

npc.getDropData().forEach(c -> list.add(c));
Collections.reverse(list);

You can iterate over the getDropData() enumerable in a reverse fashion in order to prevent the reverse call. You just add the objects in reverse before hand.

 

You can move "final int ITEMS_PER_LIST = 7;" outside of the static method to prevent the allocation to the object every time the method is called.

 

You should chain sb.append within your sb.append calls. Strings are immutable so you're allocating more memory for no reason.

 

You can change this:

 

if (_ignored.contains(itemId))
       _ignored.remove(itemId);
   else
       _ignored.add(itemId);

To this:

 

var existed = _ignored.remove(itemId);
if(!existed)
    _ignored.add(itemId);

 

You also should rename the public methods "ignoredDropContain" and "ignored" in Player.java. They are really bad names and they don't imply what they do. They also don't belong in the Player class.

 

There are other small things as well but too nit picky to mention.

  • Upvote 1
Posted (edited)

Hi, is this compatible with Interlude? Thanks! 

 

Never mind :), i successfully implemented it on my private server. The only question I have, what does the check boxes actually do? How do they work? Because i can't see any changes whatsoever.

Edited by stalker66
  • 3 weeks later...
  • 3 weeks later...
  • 1 month later...
  • 2 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...