473,508 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need Advice for my code's optimization....

539 Contributor
The code below,

//I need help here....
public void processChangedLines(int offset, int length) throws BadLocationException {
String text = getText();
ResetColor();

Set<String> syntax = keywords.keySet();
Color color ;Pattern p;Matcher m;

for (String keyword : syntax) {
color = keywords.get(keyword);
p = Pattern.compile("\\b" + keyword + "\\b");
m = p.matcher(text);
while(m.find()){
StyleConstants.setForeground(style,col);
setCharacterAttributes(m.start(),keyword.length(), style,false);
}
}
}
//I've tested the code below with all keywords in a line x 10000 lines (it is fast).... No problem here...
private void ResetColor(){
StyleConstants.setForeground(style,Color.black);
setCharacterAttributes(0,getLength(),style,false);
}

}

are the methods for coloring syntax, im currently doing my notepad that supports syntax highlighting...

I call that method when any key is pressed... " key events"

The method's performance will slow after 400 lines

I suspect the m = p.matcher(text); but i don't know the other alternatives for it....

Can anyone here advice me how to reimplement, optimize and/or give me some algorithms for that method's optimization?

Any reply will be appreciated...
A beginner, Sukatoa..
Jan 20 '08 #1
1 1108
sukatoa
539 Contributor
I need help please?!!!

My codes above implements an algorithm that states,

"compare each keyword from database to all words in the textPane"....

New algorithm "compare each word from textpane to all keywords in database"...

I believe that it is faster enough than the old one...

But the big problem is that, "I really don't know how to implement it"...
Can anyone guide me or give me some ideas, hints or classes to implement?

I really feel bad about the performance...

Any reply will be appreciated...

Michael "sukatoa"....
Jan 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2202
by: Carl Bevil | last post by:
I'm creating a library for internal use that relies on third-party code. I don't want clients of this library to know anything about the third party code, when compiling or running. Generally...
4
4208
by: Andy Reynolds | last post by:
I am looking for information, books, websites, etc that will help me figure out the following things in MSSQL and Oracle: 1. Optimizing the database configuration itself. 2. Optimal table and...
28
2447
by: Jed | last post by:
Hello to all! I have a couple of projects I intend starting on, and was wondering if someone here could make a suggestion for a good compiler and development environment. My goals are as...
31
2587
by: mark | last post by:
Hello- i am trying to make the function addbitwise more efficient. the code below takes an array of binary numbers (of size 5) and performs bitwise addition. it looks ugly and it is not elegant...
14
3104
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
16
3131
by: Ed Sutton | last post by:
I use a mutex to disallow starting a second application instance. This did not work in a release build until I made it static member of my MainForm class. In a debug build, first instance got...
10
2128
by: Mike | last post by:
Is it still true that the managed C++ compiler will produce much better opimizations than the C# compiler, or have some of the more global/aggressive opimizations been rolled into the 2005...
0
1368
by: qonhfmwfyrqx | last post by:
Discover how to quickly and easily create search engine optimized affiliate web sites that can make you money, even without any HTML knowledge or search engine optimization skills. Create...
31
2226
by: somenath | last post by:
Hi All, I was going through one of the exercise of one C tutorial . In that they have given one small code and asked about the output. #include <stdio.h> int main(void) { int x =...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.