Closed Bug 956360 Opened 11 years ago Closed 10 years ago

Use Arrays.asList when possible

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

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)

Can i grab this bug? Assign to me ok!?
Assignee: nobody → marcos.cezar.mendes
Thanks Marcos! Let me know if you have any questions.
I want to know if we have more places like this in the code that this change could be apply. Do we have?
(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.
Attached patch bug956360.diff (obsolete) — Splinter Review
Attachment #8384609 - Flags: review?(margaret.leibovic)
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)
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+
Attached patch bug956360-2.diff (obsolete) — Splinter Review
Attachment #8385427 - Flags: review?(nchen)
Attachment #8384609 - Attachment is obsolete: true
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+
Attached patch bug956360-3.diffSplinter Review
Attachment #8385734 - Flags: review?(nchen)
Attachment #8385427 - Attachment is obsolete: true
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+
When the patch will be integrated to the master branch?
Ah sorry, there should be a "checkin-needed" keyword to let someone know to check in the patch.
Status: NEW → ASSIGNED
Keywords: checkin-needed
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]
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.
Ah, thanks for catch it, Nick!
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
(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
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: