summaryrefslogtreecommitdiff
path: root/vala/valasymbol.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-08-12 00:32:50 +0200
committerJürg Billeter <j@bitron.ch>2010-08-12 14:40:15 +0200
commit664ebfd2edfae79da695252a3ba90658a5741f40 (patch)
tree97d43d14a7eb01f234652a9f2383a4f7eefc84ad /vala/valasymbol.vala
parentb597659a5fd455a0167bbe954f2c46cd8e939199 (diff)
downloadvala-664ebfd2edfae79da695252a3ba90658a5741f40.tar.gz
Do not create array lists where not necessary
Diffstat (limited to 'vala/valasymbol.vala')
-rw-r--r--vala/valasymbol.vala33
1 files changed, 23 insertions, 10 deletions
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 2fb6c3a9b..1aa5ed7c6 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -97,7 +97,7 @@ public abstract class Vala.Symbol : CodeNode {
public Comment? comment { get; set; }
- private List<string> cheader_filenames = new ArrayList<string> ();
+ private List<string> cheader_filenames;
/**
* Specifies whether this method explicitly hides a member of a base
@@ -233,6 +233,8 @@ public abstract class Vala.Symbol : CodeNode {
return "";
}
+ static List<string> _empty_string_list;
+
/**
* Returns a list of C header filenames users of this symbol must
* include.
@@ -240,16 +242,24 @@ public abstract class Vala.Symbol : CodeNode {
* @return list of C header filenames for this symbol
*/
public virtual List<string> get_cheader_filenames () {
- // parent_symbol can be null on incremental parsing
- if (cheader_filenames.size == 0 && parent_symbol != null) {
- /* default to header filenames of the namespace */
- foreach (string filename in parent_symbol.get_cheader_filenames ()) {
- add_cheader_filename (filename);
- }
+ if (cheader_filenames == null || cheader_filenames.size == 0) {
+ // parent_symbol can be null on incremental parsing
+ if (parent_symbol != null) {
+ /* default to header filenames of the namespace */
+ var parent_header_filenames = parent_symbol.get_cheader_filenames ();
+ if (parent_header_filenames.size > 0) {
+ return parent_header_filenames;
+ }
- if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
- // don't add default include directives for VAPI files
- cheader_filenames.add (source_reference.file.get_cinclude_filename ());
+ if (source_reference != null && !external_package) {
+ // don't add default include directives for VAPI files
+ add_cheader_filename (source_reference.file.get_cinclude_filename ());
+ }
+ } else {
+ if (_empty_string_list == null) {
+ _empty_string_list = new ArrayList<string> ();
+ }
+ return _empty_string_list;
}
}
return cheader_filenames;
@@ -455,6 +465,9 @@ public abstract class Vala.Symbol : CodeNode {
* @param filename a C header filename
*/
public void add_cheader_filename (string filename) {
+ if (cheader_filenames == null) {
+ cheader_filenames = new ArrayList<string> ();
+ }
cheader_filenames.add (filename);
}