diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CellBuffer.cxx | 4 | ||||
| -rw-r--r-- | src/Partitioning.h | 26 | ||||
| -rw-r--r-- | src/PerLine.cxx | 4 | ||||
| -rw-r--r-- | src/SplitVector.h | 70 | 
4 files changed, 52 insertions, 52 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index e87c5c305..1884a497a 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -394,7 +394,7 @@ const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position range  }  Sci::Position CellBuffer::GapPosition() const { -	return substance.GapPosition(); +	return static_cast<Sci::Position>(substance.GapPosition());  }  // The char* returned is to an allocation owned by the undo history @@ -457,7 +457,7 @@ const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position delete  }  Sci::Position CellBuffer::Length() const { -	return substance.Length(); +	return static_cast<Sci::Position>(substance.Length());  }  void CellBuffer::Allocate(Sci::Position newSize) { diff --git a/src/Partitioning.h b/src/Partitioning.h index 07d093ea2..85e00b328 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -16,7 +16,7 @@ namespace Scintilla {  class SplitVectorWithRangeAdd : public SplitVector<int> {  public: -	explicit SplitVectorWithRangeAdd(int growSize_) { +	explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {  		SetGrowSize(growSize_);  		ReAllocate(growSize_);  	} @@ -25,12 +25,12 @@ public:  	void operator=(const SplitVectorWithRangeAdd &) = delete;  	~SplitVectorWithRangeAdd() {  	} -	void RangeAddDelta(int start, int end, int delta) { +	void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {  		// end is 1 past end, so end-start is number of elements to change -		int i = 0; -		const int rangeLength = end - start; -		int range1Length = rangeLength; -		const int part1Left = part1Length - start; +		ptrdiff_t i = 0; +		const ptrdiff_t rangeLength = end - start; +		ptrdiff_t range1Length = rangeLength; +		const ptrdiff_t part1Left = part1Length - start;  		if (range1Length > part1Left)  			range1Length = part1Left;  		while (i < range1Length) { @@ -67,7 +67,7 @@ private:  		}  		stepPartition = partitionUpTo;  		if (stepPartition >= body->Length()-1) { -			stepPartition = body->Length()-1; +			stepPartition = Partitions();  			stepLength = 0;  		}  	} @@ -80,7 +80,7 @@ private:  		stepPartition = partitionDownTo;  	} -	void Allocate(int growSize) { +	void Allocate(ptrdiff_t growSize) {  		body.reset(new SplitVectorWithRangeAdd(growSize));  		stepPartition = 0;  		stepLength = 0; @@ -101,7 +101,7 @@ public:  	}  	int Partitions() const { -		return body->Length()-1; +		return static_cast<int>(body->Length()-1);  	}  	void InsertPartition(int partition, int pos) { @@ -132,7 +132,7 @@ public:  				BackStep(partitionInsert);  				stepLength += delta;  			} else { -				ApplyStep(body->Length()-1); +				ApplyStep(Partitions());  				stepPartition = partitionInsert;  				stepLength = delta;  			} @@ -168,10 +168,10 @@ public:  	int PartitionFromPosition(int pos) const {  		if (body->Length() <= 1)  			return 0; -		if (pos >= (PositionFromPartition(body->Length()-1))) -			return body->Length() - 1 - 1; +		if (pos >= (PositionFromPartition(Partitions()))) +			return Partitions() - 1;  		int lower = 0; -		int upper = body->Length()-1; +		int upper = Partitions();  		do {  			const int middle = (upper + lower + 1) / 2; 	// Round high  			int posMiddle = body->ValueAt(middle); diff --git a/src/PerLine.cxx b/src/PerLine.cxx index 5a213f719..2afbf3161 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -135,7 +135,7 @@ int LineMarkers::MarkValue(Sci::Line line) {  Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {  	if (lineStart < 0)  		lineStart = 0; -	const Sci::Line length = markers.Length(); +	const Sci::Line length = static_cast<Sci::Line>(markers.Length());  	for (Sci::Line iLine = lineStart; iLine < length; iLine++) {  		const MarkerHandleSet *onLine = markers[iLine].get();  		if (onLine && ((onLine->MarkValue() & mask) != 0)) @@ -281,7 +281,7 @@ int LineState::GetLineState(Sci::Line line) {  }  Sci::Line LineState::GetMaxLineState() const { -	return lineStates.Length(); +	return static_cast<Sci::Line>(lineStates.Length());  }  static int NumberLines(const char *text) { diff --git a/src/SplitVector.h b/src/SplitVector.h index c59144d1b..8c533d357 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -16,15 +16,15 @@ class SplitVector {  protected:  	std::vector<T> body;  	T empty;	/// Returned as the result of out-of-bounds access. -	int lengthBody; -	int part1Length; -	int gapLength;	/// invariant: gapLength == body.size() - lengthBody -	int growSize; +	ptrdiff_t lengthBody; +	ptrdiff_t part1Length; +	ptrdiff_t gapLength;	/// invariant: gapLength == body.size() - lengthBody +	ptrdiff_t growSize;  	/// Move the gap to a particular position so that insertion and  	/// deletion at that point will not require much copying and  	/// hence be fast. -	void GapTo(int position) { +	void GapTo(ptrdiff_t position) {  		if (position != part1Length) {  			if (position < part1Length) {  				// Moving the gap towards start so moving elements towards end @@ -45,11 +45,11 @@ protected:  	/// Check that there is room in the buffer for an insertion,  	/// reallocating if more space needed. -	void RoomFor(int insertionLength) { +	void RoomFor(ptrdiff_t insertionLength) {  		if (gapLength <= insertionLength) { -			while (growSize < static_cast<int>(body.size() / 6)) +			while (growSize < static_cast<ptrdiff_t>(body.size() / 6))  				growSize *= 2; -			ReAllocate(static_cast<int>(body.size()) + insertionLength + growSize); +			ReAllocate(body.size() + insertionLength + growSize);  		}  	} @@ -75,25 +75,25 @@ public:  	~SplitVector() {  	} -	int GetGrowSize() const { +	ptrdiff_t GetGrowSize() const {  		return growSize;  	} - -	void SetGrowSize(int growSize_) { +	 +	void SetGrowSize(ptrdiff_t growSize_) {  		growSize = growSize_;  	}  	/// Reallocate the storage for the buffer to be newSize and  	/// copy exisiting contents to the new buffer.  	/// Must not be used to decrease the size of the buffer. -	void ReAllocate(int newSize) { +	void ReAllocate(ptrdiff_t newSize) {  		if (newSize < 0)  			throw std::runtime_error("SplitVector::ReAllocate: negative size."); -		if (newSize > static_cast<int>(body.size())) { +		if (newSize > static_cast<ptrdiff_t>(body.size())) {  			// Move the gap to the end  			GapTo(lengthBody); -			gapLength += newSize - static_cast<int>(body.size()); +			gapLength += newSize - static_cast<ptrdiff_t>(body.size());  			// RoomFor implements a growth strategy but so does vector::resize so  			// ensure vector::resize allocates exactly the amount wanted by  			// calling reserve first. @@ -104,7 +104,7 @@ public:  	/// Retrieve the element at a particular position.  	/// Retrieving positions outside the range of the buffer returns empty or 0. -	const T& ValueAt(int position) const { +	const T& ValueAt(ptrdiff_t position) const {  		if (position < part1Length) {  			if (position < 0) {  				return empty; @@ -124,7 +124,7 @@ public:  	/// Setting positions outside the range of the buffer performs no assignment  	/// but asserts in debug builds.  	template <typename ParamType> -	void SetValueAt(int position, ParamType&& v) { +	void SetValueAt(ptrdiff_t position, ParamType&& v) {  		if (position < part1Length) {  			PLATFORM_ASSERT(position >= 0);  			if (position < 0) { @@ -144,7 +144,7 @@ public:  	/// Retrieve the element at a particular position.  	/// The position must be within bounds or an assertion is triggered. -	const T &operator[](int position) const { +	const T &operator[](ptrdiff_t position) const {  		PLATFORM_ASSERT(position >= 0 && position < lengthBody);  		if (position < part1Length) {  			return body[position]; @@ -156,7 +156,7 @@ public:  	/// Retrieve reference to the element at a particular position.  	/// This, instead of the const variant, can be used to mutate in-place.  	/// The position must be within bounds or an assertion is triggered. -	T &operator[](int position) { +	T &operator[](ptrdiff_t position) {  		PLATFORM_ASSERT(position >= 0 && position < lengthBody);  		if (position < part1Length) {  			return body[position]; @@ -166,13 +166,13 @@ public:  	}  	/// Retrieve the length of the buffer. -	int Length() const { +	ptrdiff_t Length() const {  		return lengthBody;  	}  	/// Insert a single value into the buffer.  	/// Inserting at positions outside the current range fails. -	void Insert(int position, T v) { +	void Insert(ptrdiff_t position, T v) {  		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));  		if ((position < 0) || (position > lengthBody)) {  			return; @@ -187,7 +187,7 @@ public:  	/// Insert a number of elements into the buffer setting their value.  	/// Inserting at positions outside the current range fails. -	void InsertValue(int position, int insertLength, T v) { +	void InsertValue(ptrdiff_t position, ptrdiff_t insertLength, T v) {  		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));  		if (insertLength > 0) {  			if ((position < 0) || (position > lengthBody)) { @@ -205,7 +205,7 @@ public:  	/// Add some new empty elements.  	/// InsertValue is good for value objects but not for unique_ptr objects  	/// since they can only be moved from once. -	void InsertEmpty(int position, int insertLength) { +	void InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength) {  		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));  		if (insertLength > 0) {  			if ((position < 0) || (position > lengthBody)) { @@ -213,7 +213,7 @@ public:  			}  			RoomFor(insertLength);  			GapTo(position); -			for (int elem = part1Length; elem < part1Length + insertLength; elem++) { +			for (ptrdiff_t elem = part1Length; elem < part1Length + insertLength; elem++) {  				T emptyOne = {};  				body[elem] = std::move(emptyOne);  			} @@ -225,14 +225,14 @@ public:  	/// Ensure at least length elements allocated,  	/// appending zero valued elements if needed. -	void EnsureLength(int wantedLength) { +	void EnsureLength(ptrdiff_t wantedLength) {  		if (Length() < wantedLength) {  			InsertEmpty(Length(), wantedLength - Length());  		}  	}  	/// Insert text into the buffer from an array. -	void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { +	void InsertFromArray(ptrdiff_t positionToInsert, const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength) {  		PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));  		if (insertLength > 0) {  			if ((positionToInsert < 0) || (positionToInsert > lengthBody)) { @@ -248,7 +248,7 @@ public:  	}  	/// Delete one element from the buffer. -	void Delete(int position) { +	void Delete(ptrdiff_t position) {  		PLATFORM_ASSERT((position >= 0) && (position < lengthBody));  		if ((position < 0) || (position >= lengthBody)) {  			return; @@ -258,7 +258,7 @@ public:  	/// Delete a range from the buffer.  	/// Deleting positions outside the current range fails. -	void DeleteRange(int position, int deleteLength) { +	void DeleteRange(ptrdiff_t position, ptrdiff_t deleteLength) {  		PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));  		if ((position < 0) || ((position + deleteLength) > lengthBody)) {  			return; @@ -277,23 +277,23 @@ public:  	/// Delete all the buffer contents.  	void DeleteAll() { -		DeleteRange(0, static_cast<int>(lengthBody)); +		DeleteRange(0, lengthBody);  	}  	/// Retrieve a range of elements into an array -	void GetRange(T *buffer, int position, int retrieveLength) const { +	void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const {  		// Split into up to 2 ranges, before and after the split then use memcpy on each. -		int range1Length = 0; +		ptrdiff_t range1Length = 0;  		if (position < part1Length) { -			const int part1AfterPosition = part1Length - position; +			const ptrdiff_t part1AfterPosition = part1Length - position;  			range1Length = retrieveLength;  			if (range1Length > part1AfterPosition)  				range1Length = part1AfterPosition;  		}  		std::copy(body.data() + position, body.data() + position + range1Length, buffer);  		buffer += range1Length; -		position = static_cast<int>(position + range1Length + gapLength); -		int range2Length = retrieveLength - range1Length; +		position = position + range1Length + gapLength; +		ptrdiff_t range2Length = retrieveLength - range1Length;  		std::copy(body.data() + position, body.data() + position + range2Length, buffer);  	} @@ -308,7 +308,7 @@ public:  	/// Return a pointer to a range of elements, first rearranging the buffer if  	/// needed to make that range contiguous. -	T *RangePointer(int position, int rangeLength) { +	T *RangePointer(ptrdiff_t position, ptrdiff_t rangeLength) {  		if (position < part1Length) {  			if ((position + rangeLength) > part1Length) {  				// Range overlaps gap, so move gap to start of range. @@ -323,7 +323,7 @@ public:  	}  	/// Return the position of the gap within the buffer. -	int GapPosition() const { +	ptrdiff_t GapPosition() const {  		return part1Length;  	}  };  | 
