optimization

ColdFusion: More efficient structKeyExists() instead of isDefined()

Which of these is more efficient in ColdFusion? isDefined('url.myvar') or structKeyExists(url, 'myvar') ...

Read Macros from External File quickly

Here is my code, For Each pj In wdApp.Application.VBE.VBProjects x = pj.FileName y = pj.Protection If x <> "" Then If y <> "1" Then For Each vbcomp In pj.VBComponents For i = 1 To vbcomp.CodeModule.CountOfLines newMacro = vbcomp.CodeModule.ProcOfLine(Lin...

Why defining class as final improves JVM performance?

Quoting from http://sites.google.com/site/gson/gson-design-document: Why are most classes in Gson marked as final? While Gson provides a fairly extensible architecture by providing pluggable serializers and deserializers, Gson classes were not specifically designed to be extensible. Providing non-final classes woul...

SQL query logic for selecting a unique subset of records from a many to many table.

I've run into quite a tough problem for my novice SQL query writing skills. I'll try and describe my problem as best I can. Table1: Account, Date, Time, Area, ResultValue, ResultString, Phone, GUID Table2: Name, Account, phone, GUID For each record in Table2 I need the the single record from Table1 that is most accurate to the follow...

Find all possible row-wise sums in a 2D array

Ideally I'm looking for a c# solution, but any help on the algorithm will do. I have a 2-dimension array (x,y). The max columns (max x) varies between 2 and 10 but can be determined before the array is actually populated. Max rows (y) is fixed at 5, but each column can have a varying number of values, something like: 1 2 3 4 5 6 7.....

Making Regular Expression more efficient

I'm attempting to determine the end of an English sentence (only approximately), by looking for "!", "?" or ".", but in the case of "." only when not preceeded by common abbreviations such as Mr. or Dr. Is there any way to make the following Regular Expression even marginally more efficient? Perhaps by sorting the negative lookbehinds ...

Image transformation: point to point

Hei! I have an image and on that image I'd like to select a point and tell it to which coordinate it should transform. I'd like to do this for some number points. And when I finish the whole image would transform, so that locality would be considered. The most import thing is that I can choose as many points as I want and that the chos...

How to optimize operations on large (75,000 items) sets of booleans in Python?

There's this script called svnmerge.py that I'm trying to tweak and optimize a bit. I'm completely new to Python though, so it's not easy. The current problem seems to be related to a class called RevisionSet in the script. In essence what it does is create a large hashtable(?) of integer-keyed boolean values. In the worst case - one fo...

What does Wordpress do on just the home page (slow loading)?

I have a problem with a wordpress site and I really can't figure out what causes it. All the pages in the site load perfectly fine, they are quite stuffed with content but the load time is ok and so is memory usage as they have no problem with a 32M memory limit set in wp-settings.php. The problem comes with the home page. It takes sev...

How much processing and memory use does casting take in Java?

Hi all, I am considering whether it is better to have two pointers, one for each object sub class and super, or whether I should just use casting. How much system resources does this use: objectName.functionOne(); ((SubClass) objectName).functionOther(); Is it better than: SuperClass objectA = (SuperClass) getSameInstance(); SubCl...

jQuery delegate optimization

what is the best way to optimize the following snippets that uses delegate()? jQuery('.menu').delegate('li.gallery', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); }); jQuery('.menu').delegate('li.interior', 'hover', function () { jQuery(this).children('.submenu').toggleClass('hide show'); }); jQuery(...

code running very slowly after importing ansi c into iphone project

I have an ANSI C code that is about 10,000 lines long that I am trying to use in an iPhone project. When I compile the code with gcc on the command line, I type the following: gcc -o myprog -O3 myprog.c This program reads in large jpeg files and does some fancy processing on them, so I call it with the following ./myprog mypic.jpg a...

Code Optimization with Scala

What structures of Scala can be used more efficiently than in Java, to increase execution speed? I don't know if this is possible, but to clear my doubts :) Thanks ...

Priority Queue with a find function - Fastest Implementation

Hi, I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions will be: insert, del-min and find. I am unsure whether I should use a Heap or a Self-balancing binary search tree. It appears PQs are usually implemented wit...

Slim down Python wxPython OS X app built with py2app?

I have just made a small little app of a Python wxPython script with py2app. Everything worked as advertised, but the app is pretty big in size. Is there any way to optimize py2app to make the app smaller in size? ...

dynamic Linq queries with Entity Framework

I am aware of few efforts in constructing Linq queries dynamically, such as this, and this. None seem to be ideal as I would like to avoid putting expressions in a string, and omitting a where if it is not needed. My main concern is that the query is optimized for the database, and dynamically omits unnecessary clauses whenever possi...

Converting a Map<Integer, Object> to Map<Integer, List<Object>>, without using for loops (java)

As the title says, I am currently implementing the below code (well about to), is their a better way - as this seems a bit nasty. Map<Integer, List<Objects>> allObjectsMap = newHashMap(); //guava for(int i=1:i<myVar:i++){ Map<Integer, Objects> eachObjectMap = getMyObjectMap(i); for(Map.Entry<Integer, Object> entry:eachObjec...

How to optimize a cycle?

I have the following bottleneck function. typedef unsigned char byte; void CompareArrays(const byte * p1Start, const byte * p1End, const byte * p2, byte * p3) { const byte b1 = 128-30; const byte b2 = 128+30; for (const byte * p1 = p1Start; p1 != p1End; ++p1, ++p2, ++p3) { *p3 = (*p1 < *p2 ) ? b1 : b2; } } ...

Optimize InnoDB database

Hi, I have a simple database table with 170MB overhead. Is this something I need to worry about? When I run optimize on it, it tells me that innodb doesn't support optimize and so recreates the table but still has 170MB overhead. Is this something I can comfortably ignore? cheers! ...

Is my programming logic correct here?

const char IsPressed = 1; // 1 const char WasHeldDown = 2; // 10 const char IsFirstPress = 4; // 100 char* keystates[256]; Class::CalculateKeyStates() { for(int i = 0; i < 256; ++i) { if(this->IsDown(i)) { keystates[i] |= IsPressed; // turn on if(keystates[i] & WasHeldDown) { ...