Skip to content

Commit

Permalink
Improve Prism.util.type performance (#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 mAAdhaTTah committed Nov 28, 2018
1 parent 10239c1 commit 2864fe2
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 2864fe2

Please sign in to comment.