Recent

Author Topic: Idea for a Lazarus addition: resource string validator  (Read 58022 times)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #15 on: December 14, 2011, 11:11:06 am »
I rewrote the ReadPoText() procedure to use Strings instead of PChars.

Original code using PChars: 6427 ticks.
New code using Strings: 300 ticks.

Wow: 20 times faster!

It is indeed faster. But why is it faster? Now a stringlist is used:
    SL.LoadFromStream(AStream);
Earlier the data was read into a string also from a stream. What makes the difference?

Is there a cross-platform alternative to "GetTickCount"? I had to comment them out what testing on Linux.

The container speed was also a surprise for me. I guess the reason is that there are only few thousand items. The speed differences become relevant only when there is much more data.

Juha
« Last Edit: December 14, 2011, 11:22:49 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #16 on: December 15, 2011, 12:43:01 pm »
I rewrote the ReadPoText() procedure to use Strings instead of PChars.

To me it looks as if handling Pascal type strings in a Pascal type mannor is faster then handling the enire data as a PChar.

In ReadPOText(s: String) the string is typecasted to a PChar and then there is much pointer-calculation to determine line-ending etc.
This overhead is redundant once we treat the data as a stringlist.

Is there a cross-platform alternative to "GetTickCount"? I had to comment them out what testing on Linux.

I'll take it out when I am happy with the testing code.
It was just crude way for me to see if I could get any speed improvement.
If I'ld have done it on Linux I simply would have used Now().

The container speed was also a surprise for me. I guess the reason is that there are only few thousand items. The speed differences become relevant only when there is much more data.

May very well be.
For the time being I leave it as is.
I can test all lazaruside.xx.po files in a matter of seconds on my ancient system.

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #17 on: December 15, 2011, 01:56:05 pm »
To me it looks as if handling Pascal type strings in a Pascal type mannor is faster then handling the enire data as a PChar.

In ReadPOText(s: String) the string is typecasted to a PChar and then there is much pointer-calculation to determine line-ending etc.
This overhead is redundant once we treat the data as a stringlist.

Could you please leave the old parser code there, too, so they are easy to compare, with IFDEF or other switch.

Mattias will have to comment on this issue. Whole codetools uses such parsing with PChar. Would it also become much faster with a stringlist? Maybe not because in pascal source the newline has no special meaning, it is just a whitespace like the other whitespace chars.
Still, 20 times speedup for PO files is a lot.

Juha
« Last Edit: December 15, 2011, 02:15:32 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #18 on: December 15, 2011, 05:28:00 pm »
Updated the sources (see link above).

Replaced the TMemo with a TSynEdit, apparantly a TMemo cannot hold the amount of text we might need.
Also the report is now on a separate form.

(I could not Tab out of the SynEdit (readonky = true, wanttabs = false), is this normal behaviour?
I worked around it in OnKeyDown of the form.)

Cleaned up the constructors (now there's only one).

Quote from: Juha
Could you please leave the old parser code there, too, so they are easy to compare, with IFDEF or other switch.

I ifdef-ed the old code with {$ifdef ReadPoTextPChar}

Bart
« Last Edit: December 16, 2011, 12:07:15 pm by Bart »

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #19 on: December 17, 2011, 04:04:55 pm »
Hi Juha,

I included an experimental po-file highlighter for the synedit in the results form.
Updated sources at: http://home.tiscali.nl/~knmg0017/software/gpocheck_bron.zip

I would like to offer the highlighter as an addition to the synedit package of Lazarus.

Some things I know what/how to do:
  • Move the synhighlighterpo.pp file to /components/synedit
  • Remove all the syn* defines and use the common include file for that
  • Add appropriate constants to syndesignstringconstants.pas
  • Add my highlighter to allsynedit.pas (?)

Things I don't know how to:
  • Make an icon for my highlighter, and make it appear on the SynEdit tab of Lazarus
  • Other steps needed ?

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #20 on: December 17, 2011, 07:57:57 pm »
The highlighter is cool.
I hope Martin or someone else can help with synedit integration. I have never worked with it.

In your GUI, the "select all tests" still creates a RunError 202. It may be caused by a recursive event handler loop and a stack overflow. Tested on Linux with QT bindings.

I was thinking if this is made a package, it could fetch all .po files under the active project, or all  .po files of a certain locale. These things can also be tweaked later. The basic functionality looks very good.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #21 on: December 18, 2011, 01:27:12 am »
In your GUI, the "select all tests" still creates a RunError 202. It may be caused by a recursive event handler loop and a stack overflow. Tested on Linux with QT bindings.

What do you mean by that?
Just clicking on the checkbox of this entry, or when indeed running the tests (after clicking the "Run Tests" button)?

B.t.w. there is no recursion in any of my code AFAIK.

It runs smoothly under windows.
I'll test GTK2 Linux.

I was thinking if this is made a package, ...

I also have no clue as how to achieve that.
Why not just have it as a stand-alone tool?

Bart

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #22 on: December 18, 2011, 01:39:07 am »
@Juha: Just saw you filed a bugreport on the issue (#20927), so it seems it's not my part of the code  O:-)

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9865
  • Debugger - SynEdit - and more
    • wiki
po hl [Re: Idea for a Lazarus addition: resource string validator]
« Reply #23 on: December 18, 2011, 02:10:40 am »
I included an experimental po-file highlighter for the synedit in the results form.
Updated sources at: http://home.tiscali.nl/~knmg0017/software/gpocheck_bron.zip

I would like to offer the highlighter as an addition to the synedit package of Lazarus.

I'll have a look at it, when I have time. Probably not before January though

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Idea for a Lazarus addition: resource string validator
« Reply #24 on: December 18, 2011, 11:06:07 am »
@Juha: Just saw you filed a bugreport on the issue (#20927), so it seems it's not my part of the code  O:-)

Correct. I was just planning to write about it.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Idea for a Lazarus addition: resource string validator
« Reply #25 on: December 18, 2011, 01:52:54 pm »
Just for my own info (so I can easily find it back).

The original bugreport for adding bat and ini highlighters is #18230 (Note that the svn wrongly states that the issue nr is #18320).


Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9865
  • Debugger - SynEdit - and more
    • wiki
Re: po hl [Re: Idea for a Lazarus addition: resource string validator]
« Reply #26 on: December 20, 2011, 12:40:41 am »
I included an experimental po-file highlighter for the synedit in the results form.
Updated sources at: http://home.tiscali.nl/~knmg0017/software/gpocheck_bron.zip

I would like to offer the highlighter as an addition to the synedit package of Lazarus.

I'll have a look at it, when I have time. Probably not before January though

I started to add it

It appears in the IDE now (for source editor)
But has empty default colors

If some one has a choice for colors, sent me an export, otherwise I will put in some random colors


As for adding to component palette, missing an icon in the same style as other hl

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: po hl [Re: Idea for a Lazarus addition: resource string validator]
« Reply #27 on: December 20, 2011, 10:23:50 pm »
I started to add it
It appears in the IDE now (for source editor)
But has empty default colors
If some one has a choice for colors, sent me an export, otherwise I will put in some random colors

I attached my editoroptions.xml (changed the extension, the forum won't let me attach xml), which provides a colorscheme for the po hl, applying the defaults as they are set in the constructor of the po hl.

Here's the relevant part of it:

Code: [Select]
    <Color Version="8">
      <Langpo_language_files Version="8">
        <SchemeDefault>
          <Key Style="fsBold"/>
          <Flags Foreground="clTeal"/>
          <String Foreground="clFuchsia"/>
          <Comment Style="fsItalic" Foreground="clGreen"/>
          <Identifier Style="fsBold" Foreground="clGreen"/>
          <Previous_value Style="fsItalic" Foreground="clOlive"/>
        </SchemeDefault>
      </Langpo_language_files>
    </Color>

Bart
« Last Edit: December 20, 2011, 11:53:58 pm by Bart »

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: po hl [Re: Idea for a Lazarus addition: resource string validator]
« Reply #28 on: December 22, 2011, 06:29:27 pm »
It appears in the IDE now (for source editor)
But has empty default colors

Why does it ovverride the default colors if no section with user defined colors exists?

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9865
  • Debugger - SynEdit - and more
    • wiki
Re: Idea for a Lazarus addition: resource string validator
« Reply #29 on: December 22, 2011, 07:16:26 pm »
Iam away for a few days.

Not sure why it doesn't use the defaults. needs to be debugged. but I am not sure I will do that anytime soon ( there are so many compatibility hacks in there.....)

 

TinyPortal © 2005-2018