Bug Tracker

Modify

Ticket #10615 (closed bug: patchwelcome)

Opened 19 months ago

Last modified 15 months ago

Consistency and concision

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

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

comment:1 Changed 19 months ago by rwaldron

  • Owner set to rwaldron
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to core
  • Milestone changed from None to 1.next

Using the literal notation is slower then Constructor.prototype.

comment:2 Changed 19 months ago by anonymous

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

comment:3 Changed 19 months ago by rwaldron

  • Status changed from assigned to closed
  • Resolution set to patchwelcome

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.