Skip to main content

Bug Tracker

Side navigation

#10615 closed bug (patchwelcome)

Opened October 29, 2011 12:53PM UTC

Closed October 30, 2011 04:57PM UTC

Last modified March 10, 2012 02:46AM UTC

Consistency and concision

Reported by: anonymous Owned by: rwaldron
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,
Attachments (0)
Change History (3)

Changed October 29, 2011 02:14PM UTC by rwaldron comment:1

component: unfiledcore
milestone: None1.next
owner: → rwaldron
priority: undecidedlow
status: newassigned

Using the literal notation is slower then Constructor.prototype.

Changed October 29, 2011 05:55PM UTC by anonymous comment:2

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

Changed October 30, 2011 04:57PM UTC by rwaldron comment:3

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"