diff options
| -rw-r--r-- | lexers/LexCPP.cxx | 18 | ||||
| -rw-r--r-- | src/CaseConvert.cxx | 6 | ||||
| -rw-r--r-- | src/Catalogue.cxx | 14 | ||||
| -rw-r--r-- | src/Document.cxx | 48 | ||||
| -rw-r--r-- | src/EditView.cxx | 10 | ||||
| -rw-r--r-- | src/Editor.cxx | 5 | ||||
| -rw-r--r-- | src/PerLine.cxx | 6 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 20 | ||||
| -rw-r--r-- | src/Selection.cxx | 32 | ||||
| -rw-r--r-- | src/XPM.cxx | 12 | 
10 files changed, 84 insertions, 87 deletions
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index bd9977b81..238856b1c 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -91,8 +91,8 @@ bool IsSpaceOrTab(int ch) {  }  bool OnlySpaceOrTab(const std::string &s) { -	for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) { -		if (!IsSpaceOrTab(*it)) +	for (const char ch : s) { +		if (!IsSpaceOrTab(ch))  			return false;  	}  	return true; @@ -100,11 +100,11 @@ bool OnlySpaceOrTab(const std::string &s) {  std::vector<std::string> StringSplit(const std::string &text, int separator) {  	std::vector<std::string> vs(text.empty() ? 0 : 1); -	for (std::string::const_iterator it = text.begin(); it != text.end(); ++it) { -		if (*it == separator) { +	for (const char ch : text) { +		if (ch == separator) {  			vs.push_back(std::string());  		} else { -			vs.back() += *it; +			vs.back() += ch;  		}  	}  	return vs; @@ -709,11 +709,11 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i  	}  	SymbolTable preprocessorDefinitions = preprocessorDefinitionsStart; -	for (std::vector<PPDefinition>::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) { -		if (itDef->isUndef) -			preprocessorDefinitions.erase(itDef->key); +	for (const PPDefinition &ppDef : ppDefineHistory) { +		if (ppDef.isUndef) +			preprocessorDefinitions.erase(ppDef.key);  		else -			preprocessorDefinitions[itDef->key] = SymbolValue(itDef->value, itDef->arguments); +			preprocessorDefinitions[ppDef.key] = SymbolValue(ppDef.value, ppDef.arguments);  	}  	std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1); diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx index 4d0e5e271..24205dd81 100644 --- a/src/CaseConvert.cxx +++ b/src/CaseConvert.cxx @@ -653,9 +653,9 @@ public:  		std::sort(characterToConversion.begin(), characterToConversion.end());  		characters.reserve(characterToConversion.size());  		conversions.reserve(characterToConversion.size()); -		for (CharacterToConversion::iterator it = characterToConversion.begin(); it != characterToConversion.end(); ++it) { -			characters.push_back(it->character); -			conversions.push_back(it->conversion); +		for (const CharacterConversion &chConv : characterToConversion) { +			characters.push_back(chConv.character); +			conversions.push_back(chConv.conversion);  		}  		// Empty the original calculated data completely  		CharacterToConversion().swap(characterToConversion); diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index 8dbe1dde0..c4f7a7eda 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -28,10 +28,9 @@ static int nextLanguage = SCLEX_AUTOMATIC+1;  const LexerModule *Catalogue::Find(int language) {  	Scintilla_LinkLexers(); -	for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin(); -		it != lexerCatalogue.end(); ++it) { -		if ((*it)->GetLanguage() == language) { -			return *it; +	for (const LexerModule *lm : lexerCatalogue) { +		if (lm->GetLanguage() == language) { +			return lm;  		}  	}  	return 0; @@ -40,10 +39,9 @@ const LexerModule *Catalogue::Find(int language) {  const LexerModule *Catalogue::Find(const char *languageName) {  	Scintilla_LinkLexers();  	if (languageName) { -		for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin(); -			it != lexerCatalogue.end(); ++it) { -			if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) { -				return *it; +		for (const LexerModule *lm : lexerCatalogue) { +			if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) { +				return lm;  			}  		}  	} diff --git a/src/Document.cxx b/src/Document.cxx index d8fdc1153..d7e3bf62b 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -134,12 +134,12 @@ Document::Document() {  }  Document::~Document() { -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifyDeleted(this, it->userData); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifyDeleted(this, watcher.userData);  	} -	for (int j=0; j<ldSize; j++) { -		delete perLineData[j]; -		perLineData[j] = 0; +	for (PerLine *&pl : perLineData) { +		delete pl; +		pl = nullptr;  	}  	regex.release();  	delete pli; @@ -149,9 +149,9 @@ Document::~Document() {  }  void Document::Init() { -	for (int j=0; j<ldSize; j++) { -		if (perLineData[j]) -			perLineData[j]->Init(); +	for (PerLine *pl : perLineData) { +		if (pl) +			pl->Init();  	}  } @@ -190,16 +190,16 @@ bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) {  }  void Document::InsertLine(Sci::Line line) { -	for (int j=0; j<ldSize; j++) { -		if (perLineData[j]) -			perLineData[j]->InsertLine(line); +	for (PerLine *pl : perLineData) { +		if (pl) +			pl->InsertLine(line);  	}  }  void Document::RemoveLine(Sci::Line line) { -	for (int j=0; j<ldSize; j++) { -		if (perLineData[j]) -			perLineData[j]->RemoveLine(line); +	for (PerLine *pl : perLineData) { +		if (pl) +			pl->RemoveLine(line);  	}  } @@ -383,8 +383,8 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {  void SCI_METHOD Document::SetErrorStatus(int status) {  	// Tell the watchers an error has occurred. -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifyErrorOccurred(this, it->userData, status); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifyErrorOccurred(this, watcher.userData, status);  	}  } @@ -2119,8 +2119,8 @@ void Document::StyleToAdjustingLineDuration(Sci::Position pos) {  void Document::LexerChanged() {  	// Tell the watchers the lexer has changed. -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifyLexerChanged(this, it->userData); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifyLexerChanged(this, watcher.userData);  	}  } @@ -2254,14 +2254,14 @@ bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) {  }  void Document::NotifyModifyAttempt() { -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifyModifyAttempt(this, it->userData); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifyModifyAttempt(this, watcher.userData);  	}  }  void Document::NotifySavePoint(bool atSavePoint) { -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifySavePoint(this, it->userData, atSavePoint); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifySavePoint(this, watcher.userData, atSavePoint);  	}  } @@ -2271,8 +2271,8 @@ void Document::NotifyModified(DocModification mh) {  	} else if (mh.modificationType & SC_MOD_DELETETEXT) {  		decorations.DeleteRange(mh.position, mh.length);  	} -	for (std::vector<WatcherWithUserData>::iterator it = watchers.begin(); it != watchers.end(); ++it) { -		it->watcher->NotifyModified(this, mh, it->userData); +	for (const WatcherWithUserData &watcher : watchers) { +		watcher.watcher->NotifyModified(this, mh, watcher.userData);  	}  } diff --git a/src/EditView.cxx b/src/EditView.cxx index d3ebeeda5..d40ac51d8 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -2036,7 +2036,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan  		} else {  			phases.push_back(drawAll);  		} -		for (std::vector<DrawPhase>::iterator it = phases.begin(); it != phases.end(); ++it) { +		for (const DrawPhase &phase : phases) {  			int ypos = 0;  			if (!bufferedDraw)  				ypos += screenLinePaintFirst * vsDraw.lineHeight; @@ -2075,7 +2075,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan  					ll->SetBracesHighlight(rangeLine, model.braces, static_cast<char>(model.bracesMatchStyle),  						static_cast<int>(model.highlightGuideColumn * vsDraw.spaceWidth), bracesIgnoreStyle); -					if (leftTextOverlap && (bufferedDraw || ((phasesDraw < phasesMultiple) && (*it & drawBack)))) { +					if (leftTextOverlap && (bufferedDraw || ((phasesDraw < phasesMultiple) && (phase & drawBack)))) {  						// Clear the left margin  						PRectangle rcSpacer = rcLine;  						rcSpacer.right = rcSpacer.left; @@ -2083,17 +2083,17 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan  						surface->FillRectangle(rcSpacer, vsDraw.styles[STYLE_DEFAULT].back);  					} -					DrawLine(surface, model, vsDraw, ll, lineDoc, visibleLine, xStart, rcLine, subLine, *it); +					DrawLine(surface, model, vsDraw, ll, lineDoc, visibleLine, xStart, rcLine, subLine, phase);  					//durPaint += et.Duration(true);  					// Restore the previous styles for the brace highlights in case layout is in cache.  					ll->RestoreBracesHighlight(rangeLine, model.braces, bracesIgnoreStyle); -					if (*it & drawFoldLines) { +					if (phase & drawFoldLines) {  						DrawFoldLines(surface, model, vsDraw, lineDoc, rcLine);  					} -					if (*it & drawCarets) { +					if (phase & drawCarets) {  						DrawCarets(surface, model, vsDraw, ll, lineDoc, xStart, rcLine, subLine);  					} diff --git a/src/Editor.cxx b/src/Editor.cxx index 78b1845db..2c7c2e5a2 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4147,9 +4147,8 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {  		std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();  		if (sel.selType == Selection::selRectangle)  			std::sort(rangesInOrder.begin(), rangesInOrder.end()); -		for (size_t r=0; r<rangesInOrder.size(); r++) { -			const SelectionRange current = rangesInOrder[r]; -			text.append(RangeText(current.Start().Position(), current.End().Position())); +		for (const SelectionRange ¤t : rangesInOrder) { +				text.append(RangeText(current.Start().Position(), current.End().Position()));  			if (sel.selType == Selection::selRectangle) {  				if (pdoc->eolMode != SC_EOL_LF)  					text.push_back('\r'); diff --git a/src/PerLine.cxx b/src/PerLine.cxx index abe2230e6..f26b48b77 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -548,9 +548,9 @@ int LineTabstops::GetNextTabstop(Sci::Line line, int x) const {  	if (line < tabstops.Length()) {  		TabstopList *tl = tabstops[line];  		if (tl) { -			for (size_t i = 0; i < tl->size(); i++) { -				if ((*tl)[i] > x) { -					return (*tl)[i]; +			for (const int i : *tl) { +				if (i > x) { +					return i;  				}  			}  		} diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 1b69fccdb..6df915b8b 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -293,16 +293,16 @@ void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesI  void LineLayoutCache::Deallocate() {  	PLATFORM_ASSERT(useCount == 0); -	for (size_t i = 0; i < cache.size(); i++) -		delete cache[i]; +	for (LineLayout *ll : cache) +		delete ll;  	cache.clear();  }  void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {  	if (!cache.empty() && !allInvalidated) { -		for (size_t i = 0; i < cache.size(); i++) { -			if (cache[i]) { -				cache[i]->Invalidate(validity_); +		for (LineLayout *ll : cache) { +			if (ll) { +				ll->Invalidate(validity_);  			}  		}  		if (validity_ == LineLayout::llInvalid) { @@ -482,7 +482,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin  			}  		}  	} -	if (pvsDraw && pvsDraw->indicatorsSetFore > 0) { +	if (pvsDraw && pvsDraw->indicatorsSetFore) {  		for (Decoration *deco = pdoc->decorations.Root(); deco; deco = deco->Next()) {  			if (pvsDraw->indicators[deco->Indicator()].OverridesTextFore()) {  				Sci::Position startPos = deco->rs.EndRun(posLineStart); @@ -639,8 +639,8 @@ PositionCache::~PositionCache() {  void PositionCache::Clear() {  	if (!allClear) { -		for (size_t i=0; i<pces.size(); i++) { -			pces[i].Clear(); +		for (PositionCacheEntry &pce : pces) { +			pce.Clear();  		}  	}  	clock = 1; @@ -700,8 +700,8 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns  		if (clock > 60000) {  			// Since there are only 16 bits for the clock, wrap it round and  			// reset all cache entries so none get stuck with a high clock. -			for (size_t i=0; i<pces.size(); i++) { -				pces[i].ResetClock(); +			for (PositionCacheEntry &pce : pces) { +				pce.ResetClock();  			}  			clock = 2;  		} diff --git a/src/Selection.cxx b/src/Selection.cxx index cc7065e3a..fe81cdf49 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -266,8 +266,8 @@ void Selection::SetMoveExtends(bool moveExtends_) {  }  bool Selection::Empty() const { -	for (size_t i=0; i<ranges.size(); i++) { -		if (!ranges[i].Empty()) +	for (const SelectionRange &range : ranges) { +		if (!range.Empty())  			return false;  	}  	return true; @@ -275,26 +275,26 @@ bool Selection::Empty() const {  SelectionPosition Selection::Last() const {  	SelectionPosition lastPosition; -	for (size_t i=0; i<ranges.size(); i++) { -		if (lastPosition < ranges[i].caret) -			lastPosition = ranges[i].caret; -		if (lastPosition < ranges[i].anchor) -			lastPosition = ranges[i].anchor; +	for (const SelectionRange &range : ranges) { +		if (lastPosition < range.caret) +			lastPosition = range.caret; +		if (lastPosition < range.anchor) +			lastPosition = range.anchor;  	}  	return lastPosition;  }  Sci::Position Selection::Length() const {  	Sci::Position len = 0; -	for (size_t i=0; i<ranges.size(); i++) { -		len += ranges[i].Length(); +	for (const SelectionRange &range : ranges) { +		len += range.Length();  	}  	return len;  }  void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) { -	for (size_t i=0; i<ranges.size(); i++) { -		ranges[i].MoveForInsertDelete(insertion, startChange, length); +	for (SelectionRange &range : ranges) { +		range.MoveForInsertDelete(insertion, startChange, length);  	}  	if (selType == selRectangle) {  		rangeRectangular.MoveForInsertDelete(insertion, startChange, length); @@ -394,11 +394,11 @@ int Selection::InSelectionForEOL(Sci::Position pos) const {  Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const {  	Sci::Position virtualSpace = 0; -	for (size_t i=0; i<ranges.size(); i++) { -		if ((ranges[i].caret.Position() == pos) && (virtualSpace < ranges[i].caret.VirtualSpace())) -			virtualSpace = ranges[i].caret.VirtualSpace(); -		if ((ranges[i].anchor.Position() == pos) && (virtualSpace < ranges[i].anchor.VirtualSpace())) -			virtualSpace = ranges[i].anchor.VirtualSpace(); +	for (const SelectionRange &range : ranges) { +		if ((range.caret.Position() == pos) && (virtualSpace < range.caret.VirtualSpace())) +			virtualSpace = range.caret.VirtualSpace(); +		if ((range.anchor.Position() == pos) && (virtualSpace < range.anchor.VirtualSpace())) +			virtualSpace = range.anchor.VirtualSpace();  	}  	return virtualSpace;  } diff --git a/src/XPM.cxx b/src/XPM.cxx index 0e5795cc5..c3b36c7ff 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -282,9 +282,9 @@ RGBAImage *RGBAImageSet::Get(int ident) {  /// Give the largest height of the set.  int RGBAImageSet::GetHeight() const {  	if (height < 0) { -		for (ImageMap::const_iterator it=images.begin(); it != images.end(); ++it) { -			if (height < it->second->GetHeight()) { -				height = it->second->GetHeight(); +		for (const std::pair<int, RGBAImage*> &image : images) { +			if (height < image.second->GetHeight()) { +				height = image.second->GetHeight();  			}  		}  	} @@ -294,9 +294,9 @@ int RGBAImageSet::GetHeight() const {  /// Give the largest width of the set.  int RGBAImageSet::GetWidth() const {  	if (width < 0) { -		for (ImageMap::const_iterator it=images.begin(); it != images.end(); ++it) { -			if (width < it->second->GetWidth()) { -				width = it->second->GetWidth(); +		for (const std::pair<int, RGBAImage*> &image : images) { +			if (width < image.second->GetWidth()) { +				width = image.second->GetWidth();  			}  		}  	}  | 
