Пример #1
0
        /// <summary>
        /// An optimized split implementation to split lines by tabs.
        /// </summary>
        /// <param name="line">Reference to the to split.</param>
        /// <returns>The split result of the provided line.</returns>
        private string[] SplitTabs(string line)
        {
            int bufferIndex = 0;

            string[]      buffer      = _bufferPool.Pop();
            StringBuilder bufferToken = new StringBuilder(line.Length / City.NUM_FIELDS);

            foreach (char c in line)
            {
                if (c == '\t')
                {
                    buffer[bufferIndex++] = bufferToken.ToString();
                    bufferToken.Clear();
                    continue;
                }
                bufferToken.Append(c);
            }
            buffer[bufferIndex] = bufferToken.ToString();
            return(buffer);
        }