This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197324 - AbstractIndenter line indent calculation algorithm does too much arrays cloning
Summary: AbstractIndenter line indent calculation algorithm does too much arrays cloning
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: Editing infrastructure (show other bugs)
Version: -S1S-
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-01 10:57 UTC by Marek Fukala
Modified: 2011-04-03 20:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2011-04-01 10:57:04 UTC
If you try to indent a bigger files with more lines you'll observe that most of the indentation time is spent in AI.calculateLineIndent() cloning arrays. There's the allCommands ArrayList containing the indent commands for all which is cloned for each line. So for long files with many lines this is unefficient.

My testing 50 000 lines css file used to be formatted for ~ 22seconds (no diffs application, already formatted code) where ~20 seconds used to be spent in the mentioned method cloning arrays.
Comment 1 Marek Fukala 2011-04-01 10:58:57 UTC
I've made a simple patch which solves the problem - extendable-only list backed by the original list. Since the allCommands list doesn't seem to escape from the method context, the solution seems safe to me.

web-main#c53d70e57e41

Davide, please review the change carefully! Thanks.
Comment 2 Quality Engineering 2011-04-02 08:48:21 UTC
Integrated into 'main-golden', will be available in build *201104020400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c53d70e57e41
User: Marek Fukala <mfukala@netbeans.org>
Log: #197324 - AbstractIndenter line indent calculation algorithm does too much arrays cloning
Comment 3 David Konecny 2011-04-03 20:35:01 UTC
(In reply to comment #0)
> where ~20 seconds used to be spent in the mentioned method cloning arrays.

Cool! Thanks major improvement. Thanks for doing that. I had a look at the code and run some unit tests and it looks perfectly OK.