This commit removes the method Strings#splitStringToArray and replaces
the call sites with invocations to String#split. There are only two
explanations for the existence of this method. The first is that
String#split is slightly tricky in that it accepts a regular expression
rather than a character to split on. This means that if s is a string,
s.split(".") does not split on the character '.', but rather splits on
the regular expression '.' which splits on every character (of course,
this is easily fixed by invoking s.split("\\.") instead). The second
possible explanation is that (again) String#split accepts a regular
expression. This means that there could be a performance concern
compared to just splitting on a single character. However, it turns out
that String#split has a fast path for the case of splitting on a single
character and microbenchmarks show that String#split has 1.5x--2x the
throughput of Strings#splitStringToArray. There is a slight behavior
difference between Strings#splitStringToArray and String#split: namely,
the former would return an empty array in cases when the input string
was null or empty but String#split will just NPE at the call site on
null and return a one-element array containing the empty string when the
input string is empty. There was only one place relying on this behavior
and the call site has been modified accordingly.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync loggly fork with current master #2
Sync loggly fork with current master #2
Changes from 1 commit
99aad3d22dc06f1a321febe239b834b583910f9df3946c7e4cb29e04a0ba3c96302fb672fb93e0cf1d166c3beaac25f8ad04bd55d2636703713c0df6c7a44cbaceabd2232a7c8c7739937382ecf349c4f07c2fbf7aca138a31b94ee322903b2ce2f5262a814c82e5640b41580cf1d0d59162fd27c8397d4cf53859fee8c728409e4372eceb8e178c48bdda49226679c15f33e616c4c250c6d6a5693c1f6fff82db0eed5cf0a6f40c98dba261385e25d01526b85d2fc03ca02d6564825321e94e68397328ca21aa0929187cd63362c8bdd31980dbe3151a53c5a8bf759ad8bf536b9ac469a90bdc6f15f35ffcb1323bc926b283a6d2247b5c82dea4499fe5ce9052191f78d615f52eb6f3c4554fe8d3427b223d67dfad07055a0cfdd34d90b04c6cf7e7656d7e124e8e567c0734230697ce49d21b07d8b3e784c9e58fc513821d716f928e2b959c135b66e8529e11b96c2cae5754b1c1163912761c4090a18ff699ee3ce6c9f3b2ab82d2b2320f778c9f1fb6a3443976d1199cd8e16af607d87087c55df19de8354db91df364ddf9167d14728e88ac1193567a2d3c5f867b69e4eb12a423b6698c3e839dade90d00fcb40b98d52537d473be01f270ed2ddebbb9901c25b0ff56521d5b9f10eaa8315be79ed3d1be072c3d3d99988105d0d2d2bc1afcb5c740feb10e3b37a78cdcd4ae5c0db352a90000dd623a468120f36c7425289343f59408ef2e3a88c52e883f3fa59b7d02fb7d1fd1752cdac46094704aef78ce214ce31ded91d5ddc531e0970c595b6f9abe54c24dfdae97aeed5b0b5a7edf9ba2fe155d8f68468e7ac4f481492b6556e27bf8e6717225d93aeb66802cf4298972f392e613f4b6a149193d1b38243c9e7667a091557fc8b319ca821c54033a45e1cc0660386546aed87a47d33ad5ce59eb1b2cf81c0b7b1c2d3b106a4f647753420a0ffe6ee8ddf5def6a7631dfbe8b531dcbfddc2c1f1d80542a63285a2bf585e5f0cc795644f49abb015b389ef46632bb4c2e4f87dd8b373c30b5b4f9d12f7b7689a1afe05ee86d288deae01a4f97a41eed0edd13e4edee5866a545d790c7680bb46b2764b47ce4af4b5189eb420af482fced8da189341d6b4e47bc5532d38adfd603b66d4025dd642d3142e3930a2158871fdd113e2399fbbd7328164cc9d5537d9ce96f55ee5cc294317b10830bd42e258379b2b474ec4825ddf4323010381de8155e1ef9667dbFile filter...
Jump to…
Remove Strings#splitStringToArray
This commit removes the method Strings#splitStringToArray and replaces the call sites with invocations to String#split. There are only two explanations for the existence of this method. The first is that String#split is slightly tricky in that it accepts a regular expression rather than a character to split on. This means that if s is a string, s.split(".") does not split on the character '.', but rather splits on the regular expression '.' which splits on every character (of course, this is easily fixed by invoking s.split("\\.") instead). The second possible explanation is that (again) String#split accepts a regular expression. This means that there could be a performance concern compared to just splitting on a single character. However, it turns out that String#split has a fast path for the case of splitting on a single character and microbenchmarks show that String#split has 1.5x--2x the throughput of Strings#splitStringToArray. There is a slight behavior difference between Strings#splitStringToArray and String#split: namely, the former would return an empty array in cases when the input string was null or empty but String#split will just NPE at the call site on null and return a one-element array containing the empty string when the input string is empty. There was only one place relying on this behavior and the call site has been modified accordingly.