Closed
Bug 956360
Opened 11 years ago
Closed 10 years ago
Use Arrays.asList when possible
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 30
People
(Reporter: jchen, Assigned: marcos.cezar.mendes)
Details
(Whiteboard: [mentor=jchen][lang=java])
Attachments
(1 file, 2 obsolete files)
13.67 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
There are some places where we fill an ArrayList manually from an existing array; Arrays.asList can be used instead for improved readability/performance. I found the following cases, * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/sqlite/SQLiteBridge.java#203 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/GeckoApp.java#707 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/browserid/verifier/BrowserIDRemoteVerifierClient.java#121 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/favicons/Favicons.java#377 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/health/BrowserHealthRecorder.java#896 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/sync/repositories/android/FormHistoryRepositorySession.java#316 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/sync/repositories/android/FormHistoryRepositorySession.java#351 * http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/sync/setup/activities/SendTabData.java#53
Assignee | ||
Comment 1•10 years ago
|
||
Can i grab this bug? Assign to me ok!?
Updated•10 years ago
|
Assignee: nobody → marcos.cezar.mendes
Reporter | ||
Comment 2•10 years ago
|
||
Thanks Marcos! Let me know if you have any questions.
Assignee | ||
Comment 3•10 years ago
|
||
I want to know if we have more places like this in the code that this change could be apply. Do we have?
Reporter | ||
Comment 4•10 years ago
|
||
(In reply to Marcos Cezar Mendes da Costa Junior from comment #3) > I want to know if we have more places like this in the code that this change > could be apply. Do we have? I'm not aware of other places. For now, it would be great to fix the places in comment 0.
Assignee | ||
Comment 5•10 years ago
|
||
Attachment #8384609 -
Flags: review?(margaret.leibovic)
Comment 6•10 years ago
|
||
Comment on attachment 8384609 [details] [diff] [review] bug956360.diff Thanks for the patch! I'm going to pass this review off to jchen, since he's more familiar with this bug and knows what needs to be done to fix it.
Attachment #8384609 -
Flags: review?(margaret.leibovic) → review?(nchen)
Reporter | ||
Comment 7•10 years ago
|
||
Comment on attachment 8384609 [details] [diff] [review] bug956360.diff Review of attachment 8384609 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/base/GeckoApp.java @@ +672,5 @@ > Intent intent = GeckoAppShell.getOpenURIIntent(sAppContext, message.optString("url"), > message.optString("mime"), message.optString("action"), message.optString("title")); > String[] handlers = GeckoAppShell.getHandlersForIntent(intent); > + > + ArrayList<String> appList = new ArrayList<String>(Arrays.asList(handlers)); You should write this line as, > List<String> appList = Arrays.asList(handlers); This is more efficient because you don't have to call "new ArrayList". Can you make this change to the other places, too? Just ask me again for review once you have a new patch. Let me know if you have questions! Thanks!
Attachment #8384609 -
Flags: review?(nchen) → feedback+
Assignee | ||
Comment 8•10 years ago
|
||
Attachment #8385427 -
Flags: review?(nchen)
Reporter | ||
Updated•10 years ago
|
Attachment #8384609 -
Attachment is obsolete: true
Reporter | ||
Comment 9•10 years ago
|
||
Comment on attachment 8385427 [details] [diff] [review] bug956360-2.diff Review of attachment 8385427 [details] [diff] [review]: ----------------------------------------------------------------- Looks great, Marcos! Thanks! :) Here's a try run, https://tbpl.mozilla.org/?tree=Try&rev=2e0cdb48aedd r+ from me if you fix the following nits: ::: mobile/android/base/browserid/verifier/BrowserIDRemoteVerifierClient.java @@ +118,5 @@ > BaseResource r = new BaseResource(verifierUri); > > r.delegate = new RemoteVerifierResourceDelegate(r, delegate); > > + List<NameValuePair> nvps = Arrays.asList(new NameValuePair[] { new BasicNameValuePair("audience", audience), Please remove the extra space at the end of this line. @@ +119,5 @@ > > r.delegate = new RemoteVerifierResourceDelegate(r, delegate); > > + List<NameValuePair> nvps = Arrays.asList(new NameValuePair[] { new BasicNameValuePair("audience", audience), > + new BasicNameValuePair("assertion", assertion) }); We want to keep lines to less than 100 characters. You can write something like, > List<NameValuePair> nvps = Arrays.asList(new NameValuePair[] { > new BasicNameValuePair("audience", audience), > new BasicNameValuePair("assertion", assertion) }); ::: mobile/android/base/favicons/Favicons.java @@ +397,5 @@ > } > > // Load and cache the built-in favicon in each of its sizes. > // TODO: don't open the zip twice! > + List<Bitmap> toInsert = Arrays.asList(loadBrandingBitmap(context, "favicon64.png"), Extra space ::: mobile/android/base/health/BrowserHealthRecorder.java @@ +790,5 @@ > new MeasurementFields() { > @Override > public Iterable<FieldSpec> getFields() { > + List<FieldSpec> out = Arrays.asList(new FieldSpec("normal", Field.TYPE_JSON_DISCRETE), > + new FieldSpec("abnormal", Field.TYPE_JSON_DISCRETE)); Line width
Attachment #8385427 -
Flags: review?(nchen) → review+
Assignee | ||
Comment 10•10 years ago
|
||
Attachment #8385734 -
Flags: review?(nchen)
Reporter | ||
Updated•10 years ago
|
Attachment #8385427 -
Attachment is obsolete: true
Reporter | ||
Comment 11•10 years ago
|
||
Comment on attachment 8385734 [details] [diff] [review] bug956360-3.diff Review of attachment 8385734 [details] [diff] [review]: ----------------------------------------------------------------- Perfect! Thanks, Marcos!
Attachment #8385734 -
Flags: review?(nchen) → review+
Assignee | ||
Comment 12•10 years ago
|
||
When the patch will be integrated to the master branch?
Reporter | ||
Comment 13•10 years ago
|
||
Ah sorry, there should be a "checkin-needed" keyword to let someone know to check in the patch.
Status: NEW → ASSIGNED
Keywords: checkin-needed
Comment 14•10 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/82f3207d8070
Keywords: checkin-needed
Whiteboard: [mentor=jchen][lang=java] → [mentor=jchen][lang=java][fixed-in-fx-team]
Comment 15•10 years ago
|
||
Hey folks, this landed code into mobile/android/base/{browserid,sync}, which are managed upstream (in the android-sync github repo). I'll port upstream.
Reporter | ||
Comment 16•10 years ago
|
||
Ah, thanks for catch it, Nick!
Comment 17•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/82f3207d8070
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [mentor=jchen][lang=java][fixed-in-fx-team] → [mentor=jchen][lang=java]
Target Milestone: --- → Firefox 30
Comment 18•10 years ago
|
||
(In reply to Nick Alexander :nalexander from comment #15) > Hey folks, this landed code into mobile/android/base/{browserid,sync}, which > are managed upstream (in the android-sync github repo). I'll port upstream. https://github.com/mozilla-services/android-sync/commit/406bb377d230f4409326ef3ba3b6b2113d7e14a9
Updated•3 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•