Skip to content

Commit 2864fe2

Browse files
RunDevelopmentmAAdhaTTah
authored andcommitted
Improve Prism.util.type performance (#1545)
Drop the regex in favor of a faster `slice` call.
1 parent 10239c1 commit 2864fe2

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

components/prism-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var _ = _self.Prism = {
3333
},
3434

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

3939
objId: function (obj) {

components/prism-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prism.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var _ = _self.Prism = {
3838
},
3939

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

4444
objId: function (obj) {

0 commit comments

Comments
 (0)