Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var WORDS = new Set()
- let file = fs.readFileSync('file.txt') // 1 500 000+ строк
- // Прошло ~10 мс
- let text = iconv.decode(file, 'windows-1251')
- // Прошло ~100 мс
- let list = text.split('n')
- // Прошло ~500 мс
- let i = 0
- while (list[i] != null) {
- // Быстрее, чем "WORDS = new Set(list)"
- WORDS.add(list[i++])
- }
- // Прошло ~1100 мс
- WORDS.has('string') // true или false
- let length = list.length;
- for(var i = 0; i < length; i++){
- Worlds.add(list[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement