Commit 8350f3a3 authored by Ben Noordhuis's avatar Ben Noordhuis
Browse files

buffer: optimize Buffer#toString()

Break up Buffer#toString() into a fast and slow path.  The fast path
optimizes for zero-length buffers and no-arg method invocation.

The speedup for zero-length buffers is a satisfying 700%.  The no-arg
toString() operation gets faster by about 13% for a one-byte buffer.

This change exploits the fact that most Buffer#toString() calls are
plain no-arg method calls.  Rewriting the method to take no arguments
means a call doesn't go through an ArgumentsAdaptorTrampoline stack
frame in the common case.

PR-URL: https://github.com/nodejs/io.js/pull/2027


Reviewed-By: default avatarBrian White <mscdex@mscdex.net>
Reviewed-By: default avatarChristian Tellnes <christian@tellnes.no>
Reviewed-By: default avatarDaniel Cousens <email@dcousens.com>
Reviewed-By: default avatarJeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: default avatarTrevor Norris <trev.norris@gmail.com>
parent 06721fe0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment