Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 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:


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 11 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 11 years ago by anonymous

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

comment:3 Changed 11 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.