Пример #1
0
 private unsafe int GetLinesImpl(NativeStringList lines)
 {
     LineParserBurst.GetLinesImpl(_info.Target,
                                  _continueBuff.GetUnsafeRef(),
                                  _charBuff.GetUnsafeRef(),
                                  lines.GetUnsafeRef(),
                                  out int line_count);
     return(line_count);
 }
Пример #2
0
            private unsafe void ParseLinesFromBuffer()
            {
                // decode byte buffer
                long byte_pos   = _info.Target->blockPos * _info.Target->decodeBlockSize;
                int  decode_len = (int)(_byteReader.Length - byte_pos);

                if (decode_len <= 0)
                {
                    return;
                }
                int byte_len = Math.Min(_info.Target->decodeBlockSize, decode_len);

                byte *byte_ptr = (byte *)_byteReader.GetUnsafePtr() + byte_pos;

                _worker.DecodeTextIntoBuffer(byte_ptr, byte_len, _decoder);

                // parse lines from buffer
                if (_info.Target->enableBurst)
                {
                    LineParserBurst.GetLines(_worker, _lines); // with Burst version
                }
                else
                {
                    _worker.GetLines(_lines);  // without Burst version
                }

                _info.Target->blockPos++;

                // termination of file
                if (_info.Target->blockPos == _info.Target->blockNum)
                {
                    if (!_worker.IsEmpty)
                    {
                        using (var buff = new NativeList <Char16>(Allocator.Temp))
                        {
                            _worker.GetInternalBuffer(buff);
                            _lines.Add((Char16 *)buff.GetUnsafePtr(), buff.Length);
                        }
                    }
                }

                /*
                 * var sb = new StringBuilder();
                 * sb.Append("decoded lines:\n");
                 * foreach(var se in _lines)
                 * {
                 *  sb.Append(se.ToString());
                 *  sb.Append('\n');
                 * }
                 * Debug.Log(sb.ToString());
                 */
            }