diff options
| -rw-r--r-- | src/ContractionState.cxx | 3 | ||||
| -rw-r--r-- | src/SparseVector.h | 4 | ||||
| -rw-r--r-- | src/SplitVector.h | 4 | ||||
| -rw-r--r-- | test/unit/testSparseVector.cxx | 16 | 
4 files changed, 22 insertions, 5 deletions
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index b513c20a6..57d9b7a1c 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -286,7 +286,8 @@ bool ContractionState<LINE>::SetFoldDisplayText(Sci::Line lineDoc, const char *t  	EnsureData();  	const char *foldText = foldDisplayTexts->ValueAt(lineDoc).get();  	if (!foldText || !text || 0 != strcmp(text, foldText)) { -		foldDisplayTexts->SetValueAt(lineDoc, UniqueStringCopy(text)); +		UniqueString uns = UniqueStringCopy(text); +		foldDisplayTexts->SetValueAt(lineDoc, std::move(uns));  		Check();  		return true;  	} else { diff --git a/src/SparseVector.h b/src/SparseVector.h index 11a126a1a..0667e54c4 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -77,11 +77,11 @@ public:  			if (position == startPartition) {  				// Already a value at this position, so replace  				ClearValue(partition); -				values->SetValueAt(partition, std::move(value)); +				values->SetValueAt(partition, std::forward<ParamType>(value));  			} else {  				// Insert a new element  				starts->InsertPartition(partition + 1, position); -				values->Insert(partition + 1, std::move(value)); +				values->Insert(partition + 1, std::forward<ParamType>(value));  			}  		}  	} diff --git a/src/SplitVector.h b/src/SplitVector.h index 16dec6e98..3fb595eef 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -130,14 +130,14 @@ public:  			if (position < 0) {  				;  			} else { -				body[position] = std::move(v); +				body[position] = std::forward<ParamType>(v);  			}  		} else {  			PLATFORM_ASSERT(position < lengthBody);  			if (position >= lengthBody) {  				;  			} else { -				body[gapLength + position] = std::move(v); +				body[gapLength + position] = std::forward<ParamType>(v);  			}  		}  	} diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index ac60d3421..ce3b9706b 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -233,4 +233,20 @@ TEST_CASE("SparseTextString") {  		REQUIRE("" == st.ValueAt(2));  		st.Check();  	} + +	SECTION("SetAndMoveString") { +		st.InsertSpace(0, 2); +		REQUIRE(2u == st.Length()); +		std::string s24("24"); +		st.SetValueAt(0, s24); +		REQUIRE("24" == s24);	// Not moved from +		REQUIRE("" == st.ValueAt(-1)); +		REQUIRE("24" == st.ValueAt(0)); +		REQUIRE("" == st.ValueAt(1)); +		std::string s25("25"); +		st.SetValueAt(1, std::move(s25)); +		REQUIRE("" == s25);	// moved from +		REQUIRE("25" == st.ValueAt(1)); +	} +  }  | 
