bug in my stack class

This commit is contained in:
Adam D. Ruppe 2013-05-22 08:49:34 -04:00
parent ab1c94de64
commit 9fc6975ada
1 changed files with 4 additions and 2 deletions

6
dom.d
View File

@ -886,7 +886,7 @@ class Element {
version(dom_node_indexes) version(dom_node_indexes)
this.dataset.nodeIndex = to!string(&(this.attributes)); this.dataset.nodeIndex = to!string(&(this.attributes));
assert(_tagName.indexOf(" ") == -1); assert(_tagName.indexOf(" ") == -1);//, "<" ~ _tagName ~ "> is invalid");
} }
/// Convenience constructor when you don't care about the parentDocument. Note this might break things on the document. /// Convenience constructor when you don't care about the parentDocument. Note this might break things on the document.
@ -5114,16 +5114,18 @@ class StyleSheet {
final class Stack(T) { final class Stack(T) {
this() { this() {
internalLength = 0; internalLength = 0;
arr = initialBuffer; arr = initialBuffer[];
} }
///. ///.
void push(T t) { void push(T t) {
if(internalLength >= arr.length) { if(internalLength >= arr.length) {
auto oldarr = arr;
if(arr.length < 4096) if(arr.length < 4096)
arr = new T[arr.length * 2]; arr = new T[arr.length * 2];
else else
arr = new T[arr.length + 4096]; arr = new T[arr.length + 4096];
arr[0 .. oldarr.length] = oldarr[];
} }
arr[internalLength] = t; arr[internalLength] = t;