Skip to content

Commit

Permalink
feat: improve some performance
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Jun 23, 2022
1 parent 07f8e46 commit d36b781
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = false
12 changes: 11 additions & 1 deletion lib/tags/compound.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

const BaseTag = require('../base_tag');

let Tags;
function getTags() {
if (Tags) {
return Tags;
}

Tags = require('../tags');
return Tags;
}

/**
* The TAGCompound class
*/
Expand Down Expand Up @@ -30,7 +40,7 @@ class TAGCompound extends BaseTag {
return -1;
}

const Tags = require('../tags');
const Tags = getTags();
const Tag = Tags[tagType];
if (Tag === null || Tag === undefined) {
throw new Error(
Expand Down
12 changes: 11 additions & 1 deletion lib/tags/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

const BaseTag = require('../base_tag');

let $tags;
function getTags() {
if ($tags) {
return $tags;
}

$tags = require('../tags');
return $tags;
}

/**
* The TAGList class
*/
Expand All @@ -13,7 +23,7 @@ class TAGList extends BaseTag {
super();
this.type = 'TAG_List';
this.childType = 'TAG_End';
this.$tags = require('../tags');
this.$tags = getTags();
}

/**
Expand Down

0 comments on commit d36b781

Please sign in to comment.