Should I use “hasClass” before “addClass”? [duplicate]
The .hasClass() check is not useful because jQuery will also always check from within .addClass(). It’s just extra work.
The .hasClass() check is not useful because jQuery will also always check from within .addClass(). It’s just extra work.
Here is the modified function: as recommended by the community, feel free to amend this its a community wiki. static double Profile(string description, int iterations, Action func) { //Run at highest priority to minimize fluctuations caused by other processes/threads Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Thread.CurrentThread.Priority = ThreadPriority.Highest; // warm up func(); var watch = new Stopwatch(); // … Read more
Very simple solution to the problem when your NetBeans or Eclipse IDE seems to be using too much memory: Disable the plugins you are not using. close the projects you are not working on. I was facing similar problem with Netbeans 7.0 on my Linux Mint as well Ubuntu box. Netbeans was using > 700 … Read more
I encountered some performance issues using the COUNT() OVER() method. (I’m not sure if it was the server as it took 40 seconds to return 10 records and then later didn’t have any issues.) This technique worked under all conditions without having to use COUNT() OVER() and accomplishes the same thing: DECLARE @PageSize INT = … Read more
mweerden: NT has been designed for multi-user from day one, so this is not really a reason. However, you are right about that process creation plays a less important role on NT than on Unix as NT, in contrast to Unix, favors multithreading over multiprocessing. Rob, it is true that fork is relatively cheap when … Read more
The 6g and 8g compilers are not particularly optimising, so the code they produce isn’t particularly fast. They’re designed to run fast themselves and produce code that’s OK (there is a bit of optimisation). gccgo uses GCC’s existing optimisation passes, and might provide a more pointful comparison with C, but gccgo isn’t feature-complete yet. Benchmark … Read more
At first glance, I thought the compiler could generate equivalent assembly for both versions with optimization flags activated. When I checked it, I was surprised to see the result: Source unoptimized.cpp note: this code is not meant to be executed. struct bitmap_t { long long width; } bitmap; int main(int argc, char** argv) { for … Read more
You can use splice combined with some apply trickery: a1 = [1,2,3,4,5]; a2 = [21,22]; a1.splice.apply(a1, [2, 0].concat(a2)); console.log(a1); // [1, 2, 21, 22, 3, 4, 5]; In ES2015+, you could use the spread operator instead to make this a bit nicer a1.splice(2, 0, …a2);
Starting with Ruby 2.4.0, you may use RegExp#match?: pattern.match?(string) Regexp#match? is explicitly listed as a performance enhancement in the release notes for 2.4.0, as it avoids object allocations performed by other methods such as Regexp#match and =~: Regexp#match? Added Regexp#match?, which executes a regexp match without creating a back reference object and changing $~ to … Read more
Here’s one way you can do this: var escape = document.createElement(‘textarea’); function escapeHTML(html) { escape.textContent = html; return escape.innerHTML; } function unescapeHTML(html) { escape.innerHTML = html; return escape.textContent; } Here’s a demo.