Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#10615 closed bug (patchwelcome)

Consistency and concision

Reported by: anonymous Owned by: Rick Waldron
Priority: low Milestone: 1.next
Component: core Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:

Description

Towards the very beginning we have:

	// Save a reference to some core methods
	toString = Object.prototype.toString,
	hasOwn = Object.prototype.hasOwnProperty,
	push = Array.prototype.push,
	slice = Array.prototype.slice,
	trim = String.prototype.trim,
	indexOf = Array.prototype.indexOf,

and then we have:

	push: push,
	sort: [].sort,
	splice: [].splice

Why not be more consistent and concise by writing the first part

	// Save a reference to some core methods
	toString = {}.toString,
	hasOwn = {}.hasOwnProperty,
	push = [].push,
	slice = [].slice,
	trim = ''.trim,
	indexOf = [].indexOf,

Change History (3)

comment:1 Changed 8 years ago by Rick Waldron

Component: unfiledcore
Milestone: None1.next
Owner: set to Rick Waldron
Priority: undecidedlow
Status: newassigned

Using the literal notation is slower then Constructor.prototype.

comment:2 Changed 8 years ago by anonymous

Aha. In that case we should maybe always use Constructor.prototype...

comment:3 Changed 8 years ago by Rick Waldron

Resolution: patchwelcome
Status: assignedclosed

Trying a number of different combinations for caching references, all seem to increase the gzipped size of the lib. Closing as "patchwelcome"

Note: See TracTickets for help on using tickets.