Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: services/prediction/dictionary_service.cc

Issue 1342973002: Initialize local arrays. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed clang warning Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <fstream> 7 #include <fstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 it != suggestion_words_reverse.end(); ++it) { 165 it != suggestion_words_reverse.end(); ++it) {
166 suggestion_words.push_back(mojo::String(*it)); 166 suggestion_words.push_back(mojo::String(*it));
167 } 167 }
168 168
169 return suggestion_words.Clone().Pass(); 169 return suggestion_words.Clone().Pass();
170 } 170 }
171 171
172 // modified from Android JniDataUtils::constructPrevWordsInfo 172 // modified from Android JniDataUtils::constructPrevWordsInfo
173 latinime::PrevWordsInfo DictionaryService::ProcessPrevWord( 173 latinime::PrevWordsInfo DictionaryService::ProcessPrevWord(
174 mojo::Array<PrevWordInfoPtr>& prev_words) { 174 mojo::Array<PrevWordInfoPtr>& prev_words) {
175 int prev_word_codepoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH]; 175 int prev_word_codepoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH] = {
176 int prev_word_codepoint_count[MAX_PREV_WORD_COUNT_FOR_N_GRAM]; 176 {0}};
177 bool are_beginning_of_sentence[MAX_PREV_WORD_COUNT_FOR_N_GRAM]; 177 int prev_word_codepoint_count[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {0};
178 bool are_beginning_of_sentence[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {false};
178 int prevwords_count = std::min( 179 int prevwords_count = std::min(
179 prev_words.size(), static_cast<size_t>(MAX_PREV_WORD_COUNT_FOR_N_GRAM)); 180 prev_words.size(), static_cast<size_t>(MAX_PREV_WORD_COUNT_FOR_N_GRAM));
180 for (int i = 0; i < prevwords_count; ++i) { 181 for (int i = 0; i < prevwords_count; ++i) {
181 prev_word_codepoint_count[i] = 0; 182 prev_word_codepoint_count[i] = 0;
182 are_beginning_of_sentence[i] = false; 183 are_beginning_of_sentence[i] = false;
183 int prev_word_size = prev_words[i]->word.size(); 184 int prev_word_size = prev_words[i]->word.size();
184 if (prev_word_size > MAX_WORD_LENGTH) { 185 if (prev_word_size > MAX_WORD_LENGTH) {
185 continue; 186 continue;
186 } 187 }
187 for (int j = 0; j < prev_word_size; j++) { 188 for (int j = 0; j < prev_word_size; j++) {
188 prev_word_codepoints[i][j] = (int)((prev_words[i])->word)[j]; 189 prev_word_codepoints[i][j] = (int)((prev_words[i])->word)[j];
189 } 190 }
190 prev_word_codepoint_count[i] = prev_word_size; 191 prev_word_codepoint_count[i] = prev_word_size;
191 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence; 192 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence;
192 } 193 }
193 latinime::PrevWordsInfo prev_words_info = 194 latinime::PrevWordsInfo prev_words_info =
194 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count, 195 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count,
195 are_beginning_of_sentence, prevwords_count); 196 are_beginning_of_sentence, prevwords_count);
196 return prev_words_info; 197 return prev_words_info;
197 } 198 }
198 199
199 } // namespace prediction 200 } // namespace prediction
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698