I am working in a wiki-like parser that creates spans for a set of markup tokens. It is working, but inside the token iterator I frequently need to convert the partial results on a SpannableStringBuilder
to a SpannableString
. This is called pretty frequently, so I'm after the most efficient solution to do it, and avoid creating extra objects.
At the moment I'm using;
SpannableStringBuilder stuff=complex_routine_that_builds_it();
SpannableString result=SpannableString.valueOf(stuff);
However this valueOf
call internally builds a SpannableString
kind of from scratch, doing a toString
and a loop to copy assigned spans
.
As SpannableStringBuilder
name suggests, I think that maybe there's a quicker way to get the SpannableString
from the builder. Is it true?