Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of StringBuffer clear reduces the usage using final on a StringBuffer . #8615

Closed
terrylucas opened this issue Feb 19, 2013 · 5 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core

Comments

@terrylucas
Copy link
Contributor

Noticed with M3 deprecation of clear method it is no longer possible to use one StringBuffer for building up a string. For example:

class A {
  final StringBuffer buff = new StringBuffer();
  String emitToDebug() => buff.toString();
  void reset() { buff.clear; }
}

must now be:

class A {
  StringBuffer buff = new StringBuffer();
  String emitToDebug() => buff.toString();
  void reset() { buff = new StringBuffer(); }
}

Unfortunate, that I can't use final and must allocate the extra object (StringBuffer) to empty my StringBuffer.

I vote to bring back clear().

@anders-sandholm
Copy link
Contributor

Added Area-Library label.

@anders-sandholm
Copy link
Contributor

Added Triaged label.

@DartBot
Copy link

DartBot commented Mar 12, 2013

This comment was originally written by @paulevans


Indeed, bring back clear.

Removing clear encourages extra allocations that give the vm more work to do. Depending on how the vm works it may not even be able to collect many composed strings in a context.

A server application that mutates many strings - or a game displaying a simple thing like framerate - could get performance penalties / frame hitches from this.

@DartBot
Copy link

DartBot commented Mar 13, 2013

This comment was originally written by @paulevans


See Issue #1216: StringBuffer in JavaScript is much slower than String https://code.google.com/p/dart/issues/detail?id=1216

If those figures of 86% hold true still I can see why they would want to sour StringBuffer

@floitschG
Copy link
Contributor

The deprecation mark on "clear" has been removed with r19930.


Added Fixed label.

@terrylucas terrylucas added Type-Defect library-core area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Mar 13, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core
Projects
None yet
Development

No branches or pull requests

4 participants