New answers tagged

0

In his answer to the OP's question, Blindman67 said: Passing a string to a function or assigning it to a variable requires the string to be copied. In a comment, radarbob said: Passing a string to a function or assigning it to a variable requires the string to be copied. The reference - the string's memory address - is copied is my understanding. ...


1

This is a half-baked answer, but you might find it useful. As far as I can tell, each keyword is processed independently. For processing one keyword you need all the categories but you don't need any other keywords. (If that's not true, then my suggestion won't be of any use). Instead of processing your keywords into a complete JSON object, you could pre-...


4

Performance Whenever possible avoid strings. Why ? JS strings are immutable Passing a string to a function or assigning it to a variable requires the string to be copied[*1]. This adds a lot of processing overhead (memory processing, (assignment, and GC), and string iteration) which can be avoided. [*1] See update at bottom of answer. For example using your ...


1

29MB csv converted to JSON Had to do something similar and process almost 30MB worth of JSON (in PHP, but same problem). While 30MB doesn't sound much, it is A LOT when it's parsed and loaded entirely as an object in memory for your app. It's not a 1:1 size of JSON = size in memory, as the object in memory contains metadata to describe object relationships, ...


1

Nicely done. The first thing I did was change your console.log to check that the results are what was expected: console.log(filterToUse, filter(objectsArr, filterToUse).map(person => person.name).toString()===[ 'John', 'Jenny' ].toString()); so that I could get true or false instead of having to look at the arrays. You might want to consider a testing ...


4

Code should be correct, maintainable, robust, reasonably efficient, and, most importantly, readable. Your code appears to be mathematically unsound. You write: deadline: 600, startTime: Date.now(), . function getTimeElapsed(startTime) { return (Date.now() - startTime) / 1000; } . getTimeElapsed(context.startTime) < context.deadline The Javascript ...


Top 50 recent answers are included