-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[java] minor performance improvements and code cleanup #14054
[java] minor performance improvements and code cleanup #14054
Conversation
according to instruction "Use scriptTimeout(Duration)"
there is no need to creat mutable lists in tests to only get elements
PR Review 🔍
|
PR Code Suggestions ✨
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #14054 +/- ##
==========================================
+ Coverage 58.48% 58.72% +0.23%
==========================================
Files 86 86
Lines 5270 5298 +28
Branches 220 227 +7
==========================================
+ Hits 3082 3111 +29
+ Misses 1968 1960 -8
- Partials 220 227 +7 ☔ View full report in Codecov by Sentry. |
Looks like the event firing decorator tests are failing. Can you investigate? |
Based on the trace of the failed tests, I suspect that the |
In the code segment that led to the test failure, there is a tricky mechanism for handling the situation where args == null
if args is null, the args2 array is created with a size sufficient only to store target.getOriginal(). Since argsLength will be zero, the for loop will not be executed, and there will be no errors in accessing the elements of args. I replaced it with |
) * replaced empty string comparison with isEmpty() invoking * replaced manual array copy with System.arraycopy() * replaced redundant String.format invoking with printf() * replaced deprecated setScriptTimeout with scriptTimeout according to instruction "Use scriptTimeout(Duration)" * replaced iterators with bulk methods invoking * replaced list creations with List.of() * there is no need to create mutable lists in tests to only get elements --------- Co-authored-by: Puja Jagani <puja.jagani93@gmail.com>
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
changes have been made to improve performance in various parts of the code.
Description
These changes help optimize the code and make it more efficient.
I also replaced some deprecated method invocations
Motivation and Context
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
isEmpty()
in multiple classes for better readability and performance.System.arraycopy()
instead of manual array copying inPrintOptions
andEventFiringDecorator
.String.format
calls withprintf
inCompletionCommand
.setScriptTimeout
withscriptTimeout
in various test files.Arrays.asList
withList.of
for immutable list creation in test files.ChromiumOptions
by using constructor initialization.RemoteLogs
by usingaddAll
.Changes walkthrough 📝
10 files
Cookie.java
Optimize empty string checks in `Cookie` class.
java/src/org/openqa/selenium/Cookie.java
isEmpty()
.ChromiumOptions.java
Simplify map initialization in `ChromiumOptions`.
java/src/org/openqa/selenium/chromium/ChromiumOptions.java
FileExtension.java
Optimize empty string checks in `FileExtension` class.
java/src/org/openqa/selenium/firefox/FileExtension.java
isEmpty()
.CompletionCommand.java
Use `printf` instead of `String.format` in `CompletionCommand`.
java/src/org/openqa/selenium/grid/commands/CompletionCommand.java
String.format
calls withprintf
.ConcatenatingConfig.java
Optimize empty string checks in `ConcatenatingConfig` class.
java/src/org/openqa/selenium/grid/config/ConcatenatingConfig.java
isEmpty()
.LogLevelMapping.java
Optimize empty string checks in `LogLevelMapping` class.
java/src/org/openqa/selenium/logging/LogLevelMapping.java
isEmpty()
.PrintOptions.java
Use `System.arraycopy` in `PrintOptions`.
java/src/org/openqa/selenium/print/PrintOptions.java
System.arraycopy
.RemoteLogs.java
Simplify list addition in `RemoteLogs`.
java/src/org/openqa/selenium/remote/RemoteLogs.java
addAll
.EventFiringDecorator.java
Use `System.arraycopy` in `EventFiringDecorator`.
java/src/org/openqa/selenium/support/events/EventFiringDecorator.java
System.arraycopy
.BazelBuild.java
Optimize empty string checks in `BazelBuild` class.
java/test/org/openqa/selenium/build/BazelBuild.java
isEmpty()
.5 files
ExecutingAsyncJavascriptTest.java
Update deprecated methods and optimize list creation in tests.
java/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java
setScriptTimeout
withscriptTimeout
.Arrays.asList
withList.of
.ExecutingJavascriptTest.java
Optimize list creation in `ExecutingJavascriptTest`.
java/test/org/openqa/selenium/ExecutingJavascriptTest.java
Arrays.asList
withList.of
.SessionQueueGridWithTimeoutTest.java
Optimize list creation in `SessionQueueGridWithTimeoutTest`.
java/test/org/openqa/selenium/grid/router/SessionQueueGridWithTimeoutTest.java
Arrays.asList
withList.of
.InternetExplorerDriverTest.java
Optimize empty string checks in `InternetExplorerDriverTest`.
java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java
isEmpty()
.RemoteWebDriverUnitTest.java
Update deprecated methods in `RemoteWebDriverUnitTest`.
java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java
setScriptTimeout
withscriptTimeout
.