[res] Speed up a check of a resource name for int
Resources.getIdentifier(name) and Resources.getValue(name) both first check if the passed name is actually an ID in a string form, and does it with Integer.parseInt(). Most of the time it isn't, and that's reported via Java exception. So the most common use case involves an exception on a regular path. This change adds a simple check to filter out all names that don't look like a number, and only try parsing those that are 'int-like', i.e. <=10 digits. This speeds up the calls by more than 2x, and gets rid of most of heap usages Bug: 282215580 Test: build + presubmits Change-Id: I1cd6be728f4e4bec04cb97729911c6a3fae0d010
Loading
Please register or sign in to comment