aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMcCabe Maxsted2011-04-13 16:56:48 -0700
committerMcCabe Maxsted2011-04-13 16:56:48 -0700
commit6cbe685381ddafa788bb96e0865dc938ee2521d1 (patch)
treeb5501392d48ea6009518b6353ae79dbd4d38157f
parentFixed crash in spellchecking when deleting selections while lagging (diff)
downloadmeta-impy-6cbe685381ddafa788bb96e0865dc938ee2521d1.zip
meta-impy-6cbe685381ddafa788bb96e0865dc938ee2521d1.tar.gz
meta-impy-6cbe685381ddafa788bb96e0865dc938ee2521d1.tar.bz2
meta-impy-6cbe685381ddafa788bb96e0865dc938ee2521d1.tar.xz
Don't create temporary vectors in spellchecking on every draw
-rw-r--r--linden/indra/llui/lllineeditor.cpp19
-rw-r--r--linden/indra/llui/lllineeditor.h5
-rw-r--r--linden/indra/llui/lltexteditor.cpp20
-rw-r--r--linden/indra/llui/lltexteditor.h8
4 files changed, 27 insertions, 25 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index 7618985..719b71a 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -580,9 +580,9 @@ void LLLineEditor::spell_show(void * data)
580 } 580 }
581} 581}
582 582
583std::vector<S32> LLLineEditor::getMisspelledWordsPositions() 583void LLLineEditor::getMisspelledWordsPositions(std::vector<S32>& misspell_positions)
584{ 584{
585 std::vector<S32> thePosesOfBadWords; 585 misspell_positions.clear();
586 const LLWString& text = mText.getWString(); 586 const LLWString& text = mText.getWString();
587 587
588 //llinfos << "end of box is at " << cursorloc << " and end of text is at " << text.length() << llendl; 588 //llinfos << "end of box is at " << cursorloc << " and end of text is at " << text.length() << llendl;
@@ -619,14 +619,13 @@ std::vector<S32> LLLineEditor::getMisspelledWordsPositions()
619 //turn this cursor position into a pixel pos 619 //turn this cursor position into a pixel pos
620 //center = findPixelNearestPos(center-getCursor()); 620 //center = findPixelNearestPos(center-getCursor());
621 621
622 thePosesOfBadWords.push_back(wordStart); 622 misspell_positions.push_back(wordStart);
623 thePosesOfBadWords.push_back(wordEnd); 623 misspell_positions.push_back(wordEnd);
624 } 624 }
625 } 625 }
626 } 626 }
627 wordEnd++; 627 wordEnd++;
628 } 628 }
629 return thePosesOfBadWords;
630} 629}
631 630
632void LLLineEditor::spell_add(void* data) 631void LLLineEditor::spell_add(void* data)
@@ -2055,16 +2054,16 @@ void LLLineEditor::drawMisspelled(LLRect background)
2055 mStartSpellHere = newStartSpellHere; 2054 mStartSpellHere = newStartSpellHere;
2056 mEndSpellHere = newStopSpellHere; 2055 mEndSpellHere = newStopSpellHere;
2057 resetSpellDirty(); 2056 resetSpellDirty();
2058 misspellLocations=getMisspelledWordsPositions(); 2057 getMisspelledWordsPositions(mMisspellLocations);
2059 } 2058 }
2060 } 2059 }
2061 2060
2062 if (!misspellLocations.empty() && glggHunSpell->getSpellCheckHighlight()) 2061 if (!mMisspellLocations.empty() && glggHunSpell->getSpellCheckHighlight())
2063 { 2062 {
2064 for (int i =0; i<(int)misspellLocations.size(); i++) 2063 for (int i =0; i<(int)mMisspellLocations.size(); i++)
2065 { 2064 {
2066 S32 wstart =findPixelNearestPos( misspellLocations[i]-getCursor()); 2065 S32 wstart =findPixelNearestPos( mMisspellLocations[i]-getCursor());
2067 S32 wend = findPixelNearestPos(misspellLocations[++i]-getCursor()); 2066 S32 wend = findPixelNearestPos(mMisspellLocations[++i]-getCursor());
2068 S32 maxw = getRect().getWidth(); 2067 S32 maxw = getRect().getWidth();
2069 2068
2070 if (wend > maxw) 2069 if (wend > maxw)
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h
index 54c0146..677d1b1 100644
--- a/linden/indra/llui/lllineeditor.h
+++ b/linden/indra/llui/lllineeditor.h
@@ -154,7 +154,8 @@ public:
154 static void spell_show(void* data); 154 static void spell_show(void* data);
155 static void spell_add(void* data); 155 static void spell_add(void* data);
156 156
157 std::vector<S32> getMisspelledWordsPositions(); 157 void getMisspelledWordsPositions(std::vector<S32>& misspell_positions);
158
158 // view overrides 159 // view overrides
159 virtual void draw(); 160 virtual void draw();
160 void autoCorrectText(); 161 void autoCorrectText();
@@ -305,7 +306,7 @@ protected:
305 std::string mPrevText; // Saved string for 'ESC' revert 306 std::string mPrevText; // Saved string for 'ESC' revert
306 LLUIString mLabel; // text label that is visible when no user text provided 307 LLUIString mLabel; // text label that is visible when no user text provided
307 std::string mPrevSpelledText; // saved string so we know whether to respell or not 308 std::string mPrevSpelledText; // saved string so we know whether to respell or not
308 std::vector<S32> misspellLocations; // where all the mispelled words are 309 std::vector<S32> mMisspellLocations; // where all the mispelled words are
309 S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update 310 S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update
310 S32 mEndSpellHere; // the location of the last char on the screen 311 S32 mEndSpellHere; // the location of the last char on the screen
311 BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field 312 BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index 963eede..5bddcbc 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -505,10 +505,10 @@ void LLTextEditor::spell_show(void * data)
505 } 505 }
506} 506}
507 507
508std::vector<S32> LLTextEditor::getMisspelledWordsPositions() 508void LLTextEditor::getMisspelledWordsPositions(std::vector<S32>& misspell_positions)
509{ 509{
510 resetSpellDirty(); 510 resetSpellDirty();
511 std::vector<S32> thePosesOfBadWords; 511 misspell_positions.clear();
512 LLWString& text = mWText; 512 LLWString& text = mWText;
513 S32 wordStart=0; 513 S32 wordStart=0;
514 S32 wordEnd=spellStart;//start at the scroll start 514 S32 wordEnd=spellStart;//start at the scroll start
@@ -538,15 +538,15 @@ std::vector<S32> LLTextEditor::getMisspelledWordsPositions()
538 { 538 {
539 //misspelled word here, and you have just right clicked on it 539 //misspelled word here, and you have just right clicked on it
540 540
541 thePosesOfBadWords.push_back(wordStart); 541 misspell_positions.push_back(wordStart);
542 thePosesOfBadWords.push_back(wordEnd); 542 misspell_positions.push_back(wordEnd);
543 } 543 }
544 } 544 }
545 } 545 }
546 wordEnd++; 546 wordEnd++;
547 } 547 }
548 return thePosesOfBadWords;
549} 548}
549
550void LLTextEditor::spell_add(void* data) 550void LLTextEditor::spell_add(void* data)
551{ 551{
552 SpellMenuBind* tempBind = (SpellMenuBind*)data; 552 SpellMenuBind* tempBind = (SpellMenuBind*)data;
@@ -3280,16 +3280,16 @@ void LLTextEditor::drawMisspelled()
3280 { 3280 {
3281 spellEnd = newSpellEnd; 3281 spellEnd = newSpellEnd;
3282 spellStart = newSpellStart; 3282 spellStart = newSpellStart;
3283 misspellLocations = getMisspelledWordsPositions(); 3283 getMisspelledWordsPositions(mMisspellLocations);
3284 } 3284 }
3285 } 3285 }
3286 //draw 3286 //draw
3287 if (!misspellLocations.empty() && glggHunSpell->getSpellCheckHighlight()) 3287 if (!mMisspellLocations.empty() && glggHunSpell->getSpellCheckHighlight())
3288 { 3288 {
3289 for (int i = 0; i<(int)misspellLocations.size() ;i++) 3289 for (int i = 0; i<(int)mMisspellLocations.size() ;i++)
3290 { 3290 {
3291 S32 wstart = misspellLocations[i]; 3291 S32 wstart = mMisspellLocations[i];
3292 S32 wend = misspellLocations[++i]; 3292 S32 wend = mMisspellLocations[++i];
3293 //start curor code mod 3293 //start curor code mod
3294 const LLWString &text = mWText; 3294 const LLWString &text = mWText;
3295 const S32 text_len = getLength(); 3295 const S32 text_len = getLength();
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h
index 1d7a735..759cd69 100644
--- a/linden/indra/llui/lltexteditor.h
+++ b/linden/indra/llui/lltexteditor.h
@@ -166,8 +166,10 @@ public:
166 static void spell_correct(void* data); 166 static void spell_correct(void* data);
167 static void spell_add(void* data); 167 static void spell_add(void* data);
168 static void spell_show(void* data); 168 static void spell_show(void* data);
169 std::vector<S32> getMisspelledWordsPositions(); 169
170 void defineMenuCallbacks(LLMenuGL* menu); 170 void getMisspelledWordsPositions(std::vector<S32>& misspell_positions);
171
172 void defineMenuCallbacks(LLMenuGL* menu);
171 173
172 void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); 174 void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE);
173 BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); 175 BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE);
@@ -535,7 +537,7 @@ private:
535 LLWString mPrevSpelledText; // saved string so we know whether to respell or not 537 LLWString mPrevSpelledText; // saved string so we know whether to respell or not
536 S32 spellStart; 538 S32 spellStart;
537 S32 spellEnd; 539 S32 spellEnd;
538 std::vector<S32> misspellLocations; // where all the mispelled words are 540 std::vector<S32> mMisspellLocations; // where all the mispelled words are
539 BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field 541 BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field
540 BOOL mAllowTranslate; // set in xui as "allow_translate". 542 BOOL mAllowTranslate; // set in xui as "allow_translate".
541 543