blackberry / WebWorks-Samples

Collection of BlackBerry WebWorks sample applications
Apache License 2.0
151 stars 143 forks source link

Potential Code optimization for stationsList.js file #41

Open amobi opened 12 years ago

amobi commented 12 years ago

I realize that this is not really a big issue, but by factoring out the repetitive SQL insert statements in the Weather stationsList.js files, this file size could be cut down by approximately 50% i believe. For example:

var stationsList = ["insert into StationList (latitude, longitude, xml_url) values (-22.017, 166.217, 'NWWW');", "insert into StationList (latitude, longitude, xml_url) values (-21.233, -175.15, 'NFTF');", ........ ];

By removing the continuously repeated string in the statement, you can then place it once in the following block:

for (var i=0; i<arrLength; i++) { tx.executeSql('insert into StationList (latitude, longitude, xml_url) values ('+stationsList[i]+');', null, incrementPercent); }

The result would be a much smaller file size. As I previously mentioned, this may not be of much importance but it does cut down file size which in my opinion is always a good thing!

astanley commented 12 years ago

Great suggestion! I agree - if you can reduce the size of resources without impacting the quality/function of an app - its a win win for everyone.

I've been wanting to see that sample refactored & improved to better support PlayBook & BB10. Your tip should be considered when that work happens (no ETA).