Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/10 18:46:04 (14 years ago)
Author:
epitzer
Message:

Estimate or calculate StringBuffer sizes in advance, use iterator over string splits instead of arrays. (#1138)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Compact/DoubleList2XmlSerializer.cs

    r3913 r3937  
    2727using HeuristicLab.Persistence.Default.Xml.Primitive;
    2828using System.Text;
     29using HeuristicLab.Persistence.Auxiliary;
    2930
    3031namespace HeuristicLab.Persistence.Default.Xml.Compact {
     
    3233  internal sealed class DoubleList2XmlSerializer : CompactXmlSerializerBase<List<double>> {
    3334
    34     private static readonly char[] separators = new char[] { ';' };
    35 
    3635    public override XmlString Format(List<double> list) {
    37       StringBuilder sb = new StringBuilder();
     36      StringBuilder sb = new StringBuilder(list.Count * 3);
    3837      foreach (var d in list) {
    3938        sb.Append(Double2XmlSerializer.FormatG17(d)).Append(';');
     
    4443    public override List<double> Parse(XmlString data) {
    4544      try {
    46         var values = data.Data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
    47         List<double> list = new List<double>(values.Length);
    48         foreach (var value in values) {
     45        List<double> list = new List<double>();
     46        foreach (var value in data.Data.EnumerateSplit(';')) {
    4947          list.Add(Double2XmlSerializer.ParseG17(value));
    5048        }
Note: See TracChangeset for help on using the changeset viewer.