Open Bug 1398572 Opened 5 years ago Updated 1 year ago

Setting input.value is rather string-usage heavy


(Core :: DOM: Editor, enhancement, P3)





(Reporter: smaug, Unassigned)


(Blocks 1 open bug)


When setting input.value we seem to copy string to local nsAutoStrings and what not. That is showing up badly in the profiles.
Maybe we could try to avoid that, at least in common cases.
I tried to do that in nsTextEditorState::SetValue() like:

nsAString* currentValue = aOldValue;
nsAutoString currentValueBuf;
if (!aOldValue) {
  currentValue = &currentValueBuf;

However, it was slower than without this kind of hack with VC. I guess that VC optimizes something even with current code but my experimental patch killed the optimization.

So, be careful about the result.
Priority: -- → P3
This is still showing up in the profiles. I couldn't immediately see how to improve the situation, but I would expect that we should be able to reuse heap allocated strings usually.

After fixing bug 1588745, TextControlState (previously called nsTextEditorState) uses nsString for new value (setting value). I think that we should create comparing method with current value instead of getting (copying) current value for the comparison.

Depends on: 1588745
You need to log in before you can comment on or make changes to this bug.