8000 Draft empty unwrapping by leebyron · Pull Request #1909 · immutable-js/immutable-js · GitHub
[go: up one dir, main page]

Skip to content

Draft empty unwrapping #1909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ ListPrototype['@@transducer/result'] = function (obj) {
return obj.asImmutable();
};

ListPrototype.__empty = emptyList;

class VNode {
constructor(array, ownerID) {
this.array = array;
Expand Down
2 changes: 2 additions & 0 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ MapPrototype['@@transducer/result'] = function (obj) {
return obj.asImmutable();
};

MapPrototype.__empty = emptyMap;

// #pragma Trie Nodes

class ArrayMapNode {
Expand Down
7 changes: 5 additions & 2 deletions src/OrderedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ export class OrderedMap extends Map {

OrderedMap.isOrderedMap = isOrderedMap;

OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
const OrderedMapPrototype = OrderedMap.prototype;
OrderedMapPrototype[IS_ORDERED_SYMBOL] = true;
OrderedMapPrototype[DELETE] = OrderedMapPrototype.remove;

OrderedMapPrototype.__empty = emptyOrderedMap;

function makeOrderedMap(map, list, ownerID, hash) {
const omap = Object.create(OrderedMap.prototype);
Expand Down
30 changes: 16 additions & 14 deletions src/Stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ export class Stack extends IndexedCollection {
}
}

function makeStack(size, head, ownerID, hash) {
const map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}

let EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}

Stack.isStack = isStack;

const StackPrototype = Stack.prototype;
Expand All @@ -210,17 +225,4 @@ StackPrototype['@@transducer/result'] = function (obj) {
return obj.asImmutable();
};

function makeStack(size, head, ownerID, hash) {
const map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}

let EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
StackPrototype.__empty = emptyStack;
0