{"action":"created","issue":{"url":"https://api.github.com/repos/google/guice/issues/993","repository_url":"https://api.github.com/repos/google/guice","labels_url":"https://api.github.com/repos/google/guice/issues/993/labels{/name}","comments_url":"https://api.github.com/repos/google/guice/issues/993/comments","events_url":"https://api.github.com/repos/google/guice/issues/993/events","html_url":"https://github.com/google/guice/issues/993","id":134919217,"number":993,"title":"Guice core optimizations","user":{"login":"stephanenicolas","id":1832925,"avatar_url":"https://avatars.githubusercontent.com/u/1832925?v=3","gravatar_id":"","url":"https://api.github.com/users/stephanenicolas","html_url":"https://github.com/stephanenicolas","followers_url":"https://api.github.com/users/stephanenicolas/followers","following_url":"https://api.github.com/users/stephanenicolas/following{/other_user}","gists_url":"https://api.github.com/users/stephanenicolas/gists{/gist_id}","starred_url":"https://api.github.com/users/stephanenicolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephanenicolas/subscriptions","organizations_url":"https://api.github.com/users/stephanenicolas/orgs","repos_url":"https://api.github.com/users/stephanenicolas/repos","events_url":"https://api.github.com/users/stephanenicolas/events{/privacy}","received_events_url":"https://api.github.com/users/stephanenicolas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-19T17:10:14Z","updated_at":"2016-02-19T17:13:31Z","closed_at":null,"body":"Hi all,\r\n\r\nI work on Android where AOP is not available, this might impact your answer to this enhancement request. \r\n\r\nWe found out that a few things can be optimized in Guice that would provide performance improvements. Performance gains would be obtained for any JVM I know of : \r\n\r\nKnowing that instanceof takes time : \r\n\r\n  * There are a few places where it could be replaced by a simpler/faster test knowing that `Class` is a final class. --> replace all `x instanceof Class` by `x.getClass() == Class`. This happens at the very heart of Guice very often, it will help to speed things up. We found only one problem during the replacement : a test breaks related to an primitive check, and you can just test if x is null to fix it, otherwise it's not needed.\r\n  * Key could be final and it's equal method should not use instanceof anymore but the getClass trick above. Key is only extended for convenience and only used in writing tests. These statements can all be replaced by using Key.get( new TypeLiteral...). Knowing that Guice is mostly about checking Keys in a hashmap, this also improves performances.\r\n  * Same as Key for Signature and AnnotationStrategies.\r\n\r\nThanks in advance,\r\n S."},"comment":{"url":"https://api.github.com/repos/google/guice/issues/comments/186309518","html_url":"https://github.com/google/guice/issues/993#issuecomment-186309518","issue_url":"https://api.github.com/repos/google/guice/issues/993","id":186309518,"user":{"login":"sameb","id":2145042,"avatar_url":"https://avatars.githubusercontent.com/u/2145042?v=3","gravatar_id":"","url":"https://api.github.com/users/sameb","html_url":"https://github.com/sameb","followers_url":"https://api.github.com/users/sameb/followers","following_url":"https://api.github.com/users/sameb/following{/other_user}","gists_url":"https://api.github.com/users/sameb/gists{/gist_id}","starred_url":"https://api.github.com/users/sameb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameb/subscriptions","organizations_url":"https://api.github.com/users/sameb/orgs","repos_url":"https://api.github.com/users/sameb/repos","events_url":"https://api.github.com/users/sameb/events{/privacy}","received_events_url":"https://api.github.com/users/sameb/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T17:13:31Z","updated_at":"2016-02-19T17:13:31Z","body":"Sorry, we can't make Key final.  Making any non-public class final sounds reasonable, though."}}