RawTherapee icon indicating copy to clipboard operation
RawTherapee copied to clipboard

Removal of obsolete strings

Open Entropy512 opened this issue 2 years ago • 3 comments

There's been some discussion of this over on pixls, but we should probably track it as its own issue.

I'm in the process of writing a tool to identify obsolete strings for removal, and have made some progress already on it.

Current version is here, I'll PR it as a WIP once I've made some more progress, right now I'm only targeting the history events table and there are already a decent number of findings:

#!/usr/bin/env python3

import clang.cindex
import subprocess

index = clang.cindex.Index.create()
procevents = index.parse('rtengine/procevents.h',args=['-x', 'c++'])

for chld in procevents.cursor.get_children():
    if(chld.displayname == 'rtengine'):
        for c in chld.get_children():
            if(c.displayname == 'ProcEventCode'):
                for pec in c.get_children():
                    #print(pec.kind, pec.displayname, pec.enum_value)
                    grp1 = subprocess.Popen(('grep', '-ro', '--exclude=procevents.h', pec.displayname), stdout=subprocess.PIPE)
                    wcr1 = subprocess.check_output(('wc', '-l'), stdin=grp1.stdout)
                    grp1.wait()
                    grp2 = subprocess.Popen(('grep', '-ro', '--exclude=procevents.h', '--exclude=refreshmap.cc', pec.displayname), stdout=subprocess.PIPE)
                    wcr2 = subprocess.check_output(('wc', '-l'), stdin=grp2.stdout)
                    grp2.wait()
                    print(pec.enum_value, pec.displayname,int(wcr1), int(wcr2))

results.txt

Grepping this for items with zero hits gives us unreferenced_in_source.txt

So over 20 events that appear to be orphaned, many of them orphaned for a few releases at this point

Next up is looking through default for unreferenced strings beyond the history events

Entropy512 avatar Apr 13 '22 14:04 Entropy512

results.txt Now includes a traversal of default

Grepped version at: orphans.txt

Entropy512 avatar Apr 13 '22 22:04 Entropy512

@Entropy512 It seems this exists https://github.com/Beep6581/RawTherapee/blob/3ad786745cf11fade334ff41aad0573dfcd7c04e/tools/generateUnusedKeys with some remarks on usage. Can you compare this with your method?

Thanatomanic avatar Apr 14 '22 03:04 Thanatomanic

Thanks, missed that one, I only saw the references to generateTranslationDiffs. I'll try and take a look tonight, it looks like traversing default may be duplicated, but traversing the history message table is not - the script explicitly states history messages as requiring full manual intervention.

This script does explain nearly all orphans in default found by my script, I'll take a look tonight to see what it does with the few unexplained orphans.

Might be beneficial to rename generateUnusedKeys to something that is more indicative of it being related to language entries.

Entropy512 avatar Apr 14 '22 11:04 Entropy512