From: Matthieu C. <cho...@gm...> - 2007-02-26 07:53:28
|
2007/2/26, Marcelo Vanzin <va...@us...>: > > Hi Alan, > > On 2/24/07, Alan Ezust <ala...@gm...> wrote: > > > I think it would be much simpler and more efficient to have a thin > > > wrapper that implements java.lang.CharSequence, and use that in place > > > of String/Segment as much as possible. The wrapper is read-only (so no > > > external code fiddling with the char array), and most interesting APIs > > > for Strings also work with CharSequence (e.g., java.util.regex). > > > > So I take it you were unable to find any such class already in the Swing > or > > JDK API? Is there a recommended class to use in its place? > > Not really. There are only a handful of CharSequence implementations, > and aside from String, all the other ones are mutable. jEdit has a > "SegmentCharSequence" implementation, but Segments are also mutable > (even if the jEdit wrapper isn't). > > Also, jEdit uses String.concat() is some places, and CharSequence > doesn't have concat(). My wrapper has a concat() implementation so we > can handle those cases easily. > > > You might want to create another branch in SVN for committing yout other > > tree to, That will save you the trouble of posting patches - you can > just > > point us all to a jedit/branches/ directory, and that will save me the > > trouble of having to independently maintain those trees too... > > I'll look into that, if I find some time to go over the subversion docs. > Hi, I think everything that could improve jEdit performances is good. And I also don't think that keeping compatibility at any price with the old api is good. We should keep this compatibility if possible, but if it make some improvement impossible, the compatibility could be dropped. Of course if you can have both api it is the best :). The thing that I did not understood is that you says that your wrapper is read only. But I suppose you will use the same char[] that is in the ContentManager in your wrapper right ? So if the content of the buffer changes the wrapper will be changed isn't it ? Matthieu |