We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding keywords very slow

I''ve been using the Addkeyword method to add syntax highlighting dynamically, and find that this method seems to take an unreasonable amount of time. Inserting say 130 keywords takes around 10 seconds even on a 3GHz machine. Strangely, adding the same keywords a second time takes virtually no time. Is the control performing some sort of horrible insertion sort? Is there a way to stop it until all the keywords have been loaded? Is there a quick way to remove all keywords, or do I have to remove them one at a time? Thanks for any advice. David Loomes

9 Replies

GP Gurucharan Patwal Syncfusion Team December 4, 2003 10:10 PM UTC

Hi David, We are unable to be specific, but one of the possible reasons could be that EditControl "refreshes" it''s internal data structures for each Add and Remove keywords call. Looks like a "suspend refresh" property will be of a big help in the EditControl. We will try our best to add such a property in our future releases. Regards, Guru Patwal Syncfusion, Inc.

DL David Loomes December 5, 2003 08:32 AM UTC

Guru, Thanks for the info. I did some more testing and I''m afraid the figures aren''t very good. Adding the first 5 keywords takes around 30ms on a 3.2GHz P4! As keywords are added, the time to add each new one rises linearly, so that by the time there are 100 keywords, adding another 5 to the list takes 300ms. Once the list has reached 130, each new keyword requires >100ms. The net result is the time taken to build a keyword list with N entries increase with N^2. The order in which the keywords are added makes no noticeable difference. I''m afraid this behaviour isn''t terribly useful. David Loomes

GP Gurucharan Patwal Syncfusion Team December 5, 2003 08:26 PM UTC

Hi David, Thanks for the additional information. We do realise that this needs to be addressed at the earliest and have considered it as a high priority issue. I will keep updated regarding the developments as we investigate this. We appreciate your patience and understanding in this matter. Regards, Guru Patwal Syncfusion, Inc.

DL David Loomes December 6, 2003 05:03 PM UTC

Guru, a related problem. To get round the time taken to add keywords, I tried generating a complete INI file dynamically, and using the ''FromStream'' function to load the stream. This works with the required speed, but extended characters (Chinese, Japanese etc) are not recognised. Odd, since they work correctly if added individually via AddKeyword. It would be nice if your guys could sort this out too. David Loomes

GP Gurucharan Patwal Syncfusion Team December 8, 2003 07:15 PM UTC

Hi David, Thanks for your feedback on these finer issues. We will look into the problem in handling the extended characters as well. We appreciate your continued interest in Syncfusion products. Regards, Guru Patwal. Syncfusion, Inc.

ME Marco Ensing February 2, 2004 06:22 PM UTC

What is the current status on this issue with respect to the lattest release Marco

AD Administrator Syncfusion Team February 3, 2004 08:49 PM UTC

Hi Marco, I have requested the development team for information on the status of this issue, and will update you as soon as they get back to me. Thanks for your patience and cooperation. Regards, Guru Patwal Syncfusion, Inc.

ME Marco Ensing February 5, 2004 08:20 PM UTC

I''ve implemented the suggested workaround as a memory stream. Works great. No complaints. But I can image that new users might find the writing of the workaround cumbersome. Here is the code for anybody out there looking for it: Create a default .ini file and compile it into the assembly as a resource. assume: Terms.ini file has your initial settings. executingAssembly = Assembly.GetExecutingAssembly(); internal System.IO.Stream ExtendIniFile(System.Collections.ICollection terms) { System.IO.Stream iniStream = executingAssembly.GetManifestResourceStream("YourAssembly.Terms.ini"); //Build the extension string extension; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); foreach (string item in terms) { stringBuilder.AppendFormat("Keyword={0}\n", item); } extension = stringBuilder.ToString(); //Memory stream is initial lenght + extension System.IO.MemoryStream memoryStream = new System.IO.MemoryStream((int) iniStream.Length + (int) extension.Length); System.IO.BinaryReader reader = new System.IO.BinaryReader(iniStream); byte[] buffer = reader.ReadBytes((int) iniStream.Length); memoryStream.Write(buffer, 0, (int) iniStream.Length); byte[] buffer2 = System.Text.Encoding.Default.GetBytes(extension); memoryStream.Write(buffer2, 0, (int) extension.Length); memoryStream.Flush(); //For quick testing FileStream fs = new FileStream(@"C:\RESULT.INI", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default); memoryStream.WriteTo(sw.BaseStream); sw.Close(); memoryStream.Position = 0; return memoryStream; } And the EditControl is initialized with this.editControl1.UseSettingStream(this.resourceHandler.ExtendIniFile(dataService.getTermLookupTable().Keys)); I don''t know too much about streams but it does the Job. I''m not too sure yet about the used encoding and if that influences the editControl. Regards, Marco

AD Administrator Syncfusion Team February 5, 2004 09:16 PM UTC

Hi Marco, Thanks for sharing this information with us. We apreciate your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Live Chat Icon For mobile
Up arrow icon