Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 3:47 am

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Sep 21, 2012 12:51 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
It is worth mentioning that the patch uses == as first comparison, failing to equals comparison. So if you're using a constant you'll reap the benefits of the == check, that is if the two string objects are the same.

It's also worth mentioning that the GroupManager is simply an addon, it's not a vital part of the framework. In fact, if you feel that the GroupManager is insufficient you can easily make your own by extending Manager, the framework promotes that just as well as it promotes you creating your own systems.
There are many ways to implement a GroupManager. I could have had two implementations, standard GroupManager that only associated one group to an entity and a MultiGroupManager, where you could put an entity into multiple groups.
I'm pretty sure there are better ways to implement a GroupManager, don't consider the bundled version to be the holy truth :)

You can also create a GroupingSystem and a Grouping component, but that would be more experimental, which I'd like to know how works out.


Top
 Profile  
 
PostPosted: Fri Sep 21, 2012 5:39 am 
Offline

Joined: Sun Aug 05, 2012 3:37 pm
Posts: 23
Checking for == is redundant in your patch from what I'm seeing defined for java.lang.String:

Code:
    public boolean equals(Object anObject) {
   if (this == anObject) {
       return true;
   }
   if (anObject instanceof String) {
       String anotherString = (String)anObject;
       int n = count;
       if (n == anotherString.count) {
      char v1[] = value;
      char v2[] = anotherString.value;
      int i = offset;
      int j = anotherString.offset;
      while (n-- != 0) {
          if (v1[i++] != v2[j++])
         return false;
      }
      return true;
       }
   }
   return false;
    }


--tim


Top
 Profile  
 
PostPosted: Fri Sep 21, 2012 5:54 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
Also hotspot has an hand optimized assembler version for String.equals, String.compareTo and String.indexOf and inlines the first identity check.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group