2005-01-27 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 27 Jan 2005 05:18:19 +0000 (05:18 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 27 Jan 2005 05:18:19 +0000 (05:18 -0000)
* DataTable.cs : don't create DefaultView unless it is required. It
  significantly improves performance. (i.e. DataView perf. is sick ;-)

svn path=/trunk/mcs/; revision=39621

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataTable.cs

index fa38a81802432e446db4981b1a81473f41690b9b..2375a65183e9c4e811b5e2bdc4407beef80bf173 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataTable.cs : don't create DefaultView unless it is required. It
+         significantly improves performance. (i.e. DataView perf. is sick ;-)
+
 2005-01-27  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataViewSetting.cs,
index febf3ac4b8205c3f3e4b4ff105e3fe65f67db47e..5563dfb4094d68413c184118bee77427abe8c00c 100644 (file)
@@ -66,6 +66,7 @@ namespace System.Data {
                private bool _caseSensitive;
                private DataColumnCollection _columnCollection;
                private ConstraintCollection _constraintCollection;
+               // never access it. Use DefaultView.
                private DataView _defaultView;
 
                private string _displayExpression;
@@ -126,8 +127,6 @@ namespace System.Data {
                        
                        _childRelations = new DataRelationCollection.DataTableRelationCollection (this);
                        _parentRelations = new DataRelationCollection.DataTableRelationCollection (this);
-
-                       _defaultView = new DataView(this);
                }
 
                /// <summary>
@@ -283,7 +282,11 @@ namespace System.Data {
                [Browsable (false)]
                [DataSysDescription ("This is the default DataView for the table.")]
                public DataView DefaultView {
-                       get { return _defaultView; }
+                       get {
+                               if (_defaultView == null)
+                                       _defaultView = new DataView (this);
+                               return _defaultView;
+                       }
                }
                
 
@@ -934,7 +937,7 @@ namespace System.Data {
                /// </summary>
                IList IListSource.GetList () 
                {
-                       IList list = (IList) _defaultView;
+                       IList list = (IList) DefaultView;
                        return list;
                }