1 //------------------------------------------------------------------------------
2 // <copyright file="ByteStack.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">[....]</owner>
6 //------------------------------------------------------------------------------
10 namespace System.Xml {
12 // This stack is designed to minimize object creation for the
13 // objects being stored in the stack by allowing them to be
14 // re-used over time. It basically pushes the objects creating
15 // a high water mark then as Pop() is called they are not removed
16 // so that next time Push() is called it simply returns the last
17 // object that was already on the stack.
19 internal class ByteStack {
21 private int growthRate;
25 public ByteStack(int growthRate) {
26 this.growthRate = growthRate;
28 stack = new byte[growthRate];
32 public void Push(byte data) {
34 byte[] newstack = new byte[size + growthRate];
36 Buffer.BlockCopy(stack, 0, newstack, 0, top);
54 return stack[top - 1];