public static string Format(InsAssembly assembly)
        {
            if (assembly.Qualifications.Length == 0 && assembly.Name.AsSpan().IndexOfAny(Delimiters.All) < 0)
            {
                return(assembly.Name);
            }

            return(Write(BuilderPool.Rent(), assembly).ToStringAndReturn());
        }
Ejemplo n.º 2
0
        static string FormatBlob(ReadOnlySpan <byte> blob)
        {
            if (blob.Length == 0)
            {
                return(string.Empty);
            }

            var builder    = BuilderPool.Rent(blob.Length * 2);
            var charLookup = "0123456789ABCDEF";

            for (var i = 0; i < blob.Length; i++)
            {
                var b = blob[i];

                builder
                .Append(charLookup[b >> 4])
                .Append(charLookup[b & 0xF]);
            }

            return(builder.ToStringAndReturn());
        }
            string ParseIdentifierCore(ref int index, ReadOnlySpan <char> delimiters)
            {
                AssertNotEOF(index);

                var           start   = index;
                StringBuilder?builder = null;

                while (true)
                {
                    var i = _buffer.Slice(index).IndexOfAny(delimiters);

                    if (i < 0)
                    {
                        index = _buffer.Length;
                        break;
                    }

                    index += i;

                    if (_buffer[index] != '\\')
                    {
                        break;
                    }

                    builder ??= BuilderPool.Rent();
                    builder.Append(_buffer.Slice(start, index - start));
                    start = index + 1;

                    AssertNotEOF(start);
                    index = start + 1;
                }

                var section = _buffer.Slice(start, index - start);

                return(builder == null
                                        ? section.ToString()
                                        : builder.Append(section).ToStringAndReturn());
            }
 public static string Format(InsType type) => Write(BuilderPool.Rent(), type).ToStringAndReturn();