Skip to content

Commit

Permalink
Improve Prism.util.type performance (PrismJS#1545)
Browse files Browse the repository at this point in the history
Drop the regex in favor of a faster `slice` call.
  • Loading branch information
RunDevelopment authored and ggrossetie committed Mar 11, 2019
1 parent 8347713 commit 30994f9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = _self.Prism = {
},

type: function (o) {
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
return Object.prototype.toString.call(o).slice(8, -1);
},

objId: function (obj) {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = _self.Prism = {
},

type: function (o) {
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
return Object.prototype.toString.call(o).slice(8, -1);
},

objId: function (obj) {
Expand Down

0 comments on commit 30994f9

Please sign in to comment.