зеркало из https://github.com/mozilla/gecko-dev.git
Bug 170160 - don't use sprintf for simple tasks as converting a number to a string. It's expensive and give you an ASCII string when a Unicode one is required. r=bryner@netscape.com, sr=brendan@mozilla.org
This commit is contained in:
Родитель
2457dd3be2
Коммит
bf387aaa22
|
@ -203,14 +203,12 @@ nsScrollbarButtonFrame::MouseClicked()
|
|||
}
|
||||
|
||||
// set the current position of the slider.
|
||||
char v[100];
|
||||
sprintf(v, "%d", curpos);
|
||||
nsAutoString curposStr;
|
||||
curposStr.AppendInt(curpos);
|
||||
|
||||
content->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, NS_ConvertASCIItoUCS2(v), PR_TRUE);
|
||||
|
||||
content->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, curposStr, PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -264,9 +264,9 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
char ch[100];
|
||||
sprintf(ch,"%d", current);
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, NS_ConvertASCIItoUCS2(ch), PR_FALSE);
|
||||
nsAutoString currentStr;
|
||||
currentStr.AppendInt(current);
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, currentStr, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,22 +859,22 @@ nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame,
|
|||
scrollbarFrame->GetScrollbarMediator(getter_AddRefs(mediator));
|
||||
if (mediator) {
|
||||
mediator->PositionChanged(GetCurrentPosition(scrollbar), newpos);
|
||||
char ch[100];
|
||||
sprintf(ch,"%d", newpos);
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, NS_ConvertASCIItoUCS2(ch), PR_FALSE);
|
||||
nsAutoString newposStr;
|
||||
newposStr.AppendInt(newpos);
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, newposStr, PR_FALSE);
|
||||
CurrentPositionChanged(mPresContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char ch[100];
|
||||
sprintf(ch,"%d", newpos);
|
||||
nsAutoString newposStr;
|
||||
newposStr.AppendInt(newpos);
|
||||
|
||||
// set the new position
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, NS_ConvertASCIItoUCS2(ch), PR_TRUE);
|
||||
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::curpos, newposStr, PR_TRUE);
|
||||
|
||||
#ifdef DEBUG_SLIDER
|
||||
printf("Current Pos=%s\n",ch);
|
||||
printf("Current Pos=%d\n",newpos);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -1222,14 +1222,14 @@ nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildB
|
|||
childFrame->GetContent(getter_AddRefs(content));
|
||||
|
||||
// set its preferred size.
|
||||
char ch[50];
|
||||
sprintf(ch,"%d",pref/aOnePixel);
|
||||
nsAutoString prefValue;
|
||||
prefValue.AppendInt(pref/aOnePixel);
|
||||
nsAutoString oldValue;
|
||||
content->GetAttr(kNameSpaceID_None, attribute, oldValue);
|
||||
if (oldValue.EqualsWithConversion(ch))
|
||||
if (oldValue.Equals(prefValue))
|
||||
return;
|
||||
|
||||
content->SetAttr(kNameSpaceID_None, attribute, NS_ConvertASCIItoUCS2(ch), PR_TRUE);
|
||||
content->SetAttr(kNameSpaceID_None, attribute, prefValue, PR_TRUE);
|
||||
aChildBox->MarkDirty(aState);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче