Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Newsgroups: comp.lang.java.programmer From: Andreas Leitgeb Subject: Re: slow as molasses References: Reply-To: avl@logic.at User-Agent: slrn/pre0.9.9-111 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: Date: 04 Oct 2011 11:28:10 GMT Lines: 25 NNTP-Posting-Host: gamma.logic.tuwien.ac.at X-Trace: 1317727690 tunews.univie.ac.at 11354 128.130.175.3 X-Complaints-To: abuse@tuwien.ac.at Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8516 bob wrote: > So, I wrote some code, but it is slow as molasses. Any easy ways to > speed this up? > float[] getVertices(String filename) { > try { > AssetManager am = this.getResources().getAssets(); > InputStream is = am.open(filename); Just speculating: Involving some of the Buffered* stream-wrappers here might help big time. > Scanner s = new Scanner(is); > long numfloats = s.nextLong(); > float[] f = new float[(int) numfloats]; > for (int ctr = 0; ctr < f.length; ctr++) { > f[ctr] = s.nextFloat(); > } > return f; > > } catch (IOException e) { > e.printStackTrace(); > return null; > } > > }