[cfe-commits] r43895 - /cfe/trunk/include/clang/Rewrite/RewriteRope.h
Chris Lattner
sabre at nondot.org
Thu Nov 8 09:59:48 PST 2007
Author: lattner
Date: Thu Nov 8 11:59:48 2007
New Revision: 43895
URL: http://llvm.org/viewvc/llvm-project?rev=43895&view=rev
Log:
Simplify interface to MakeRopeString.
Modified:
cfe/trunk/include/clang/Rewrite/RewriteRope.h
Modified: cfe/trunk/include/clang/Rewrite/RewriteRope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/RewriteRope.h?rev=43895&r1=43894&r2=43895&view=diff
==============================================================================
--- cfe/trunk/include/clang/Rewrite/RewriteRope.h (original)
+++ cfe/trunk/include/clang/Rewrite/RewriteRope.h Thu Nov 8 11:59:48 2007
@@ -32,7 +32,11 @@
RopePiece(RopeRefCountString *Str, unsigned Start, unsigned End)
: StrData(Str), StartOffs(Start), EndOffs(End) {
- StrData->RefCount++;
+ ++StrData->RefCount;
+ }
+ RopePiece(const RopePiece &RP)
+ : StrData(RP.StrData), StartOffs(RP.StartOffs), EndOffs(RP.EndOffs) {
+ ++StrData->RefCount;
}
~RopePiece() {
@@ -162,8 +166,7 @@
void assign(const char *Start, const char *End) {
clear();
- Chunks.push_back(new RopePiece(MakeRopeString(Start, End), 0,
- End-Start));
+ Chunks.push_back(new RopePiece(MakeRopeString(Start, End)));
CurSize = End-Start;
}
@@ -172,8 +175,8 @@
unsigned ChunkNo = SplitAt(Loc);
- RopeRefCountString *Str = MakeRopeString(Start, End);
- Chunks.insert(Chunks.begin()+ChunkNo, new RopePiece(Str, 0, End-Start));
+ Chunks.insert(Chunks.begin()+ChunkNo,
+ new RopePiece(MakeRopeString(Start, End)));
CurSize += End-Start;
}
@@ -253,13 +256,13 @@
}
private:
- RopeRefCountString *MakeRopeString(const char *Start, const char *End) {
+ RopePiece MakeRopeString(const char *Start, const char *End) {
unsigned Size = End-Start+sizeof(RopeRefCountString)-1;
RopeRefCountString *Res =
reinterpret_cast<RopeRefCountString *>(new char[Size]);
Res->RefCount = 0;
memcpy(Res->Data, Start, End-Start);
- return Res;
+ return RopePiece(Res, 0, End-Start);
}
unsigned getChunkIdx(iterator Loc) const {
More information about the cfe-commits
mailing list