Modernizing Kile code (WIP)
AbandonedPublic

Authored by ognarb on Sep 25 2018, 8:33 PM.

Details

Reviewers
pino
mludwig
Group Reviewers
Kile
Summary

The purpose of this diff is to modernizing the code from kile and understand the architecture of kile. I'm still looking for small fix and looking for any introduced bug with this modification.

Change contains:

+ The use of the range based loop. I did it semi-automaticly with the help from clang-tidy.
+ Use of default keyword for empty constructor and destructor
+ Simplify some if condition. Ex: if (a) { return true; } else { return false; }
+ Use List::empty or QList::isEmpty instead of comparing the length with 0.
+ Rewrite the plain text to latex converter using QString::replace. Note: I will propably replace it later with a regex.

Notable modification are in:
+ src/plaintolatexconverter.cpp
+ src/kile.cpp:2536

Some strange/buggy code:
+ src/editorextention.cpp:267 allDeleted is always false

Diff Detail

Repository
R468 Kile
Lint
Lint Skipped
Unit
Unit Tests Skipped
ognarb created this revision.Sep 25 2018, 8:33 PM
Restricted Application added a subscriber: Kile. · View Herald TranscriptSep 25 2018, 8:33 PM
ognarb requested review of this revision.Sep 25 2018, 8:33 PM
ognarb added a reviewer: Kile.
pino requested changes to this revision.Sep 25 2018, 9:38 PM
pino added a subscriber: pino.

Hi, thanks for all the interest in KDE software, and kile in particular.

While I'm not a kile developer, I really think doing a single giant commit with lots of unrelated changes is not a good idea: it is really hard to review, and in case you need to debug a regression introduced with this commit then you need to inspect lots of changes.
So my advice is to split this commit into all the various topics, so it can be reviewed easily.

This revision now requires changes to proceed.Sep 25 2018, 9:38 PM
ognarb added a comment.EditedSep 25 2018, 10:20 PM

Thank you for your feedback, I will try to rebase this 'giant' commit :)

mludwig requested changes to this revision.Sep 26 2018, 3:49 AM
mludwig added a subscriber: mludwig.

Also, please leave the variable names as they are and don't introduce 'auto' everywhere. It's useful to know which type one is working with, even if it means that one has to write longer code.

What are the advantages of the following?

+ Use List::empty or QList::isEmpty instead of comparing the length with 0.

Please also make sure that the code can still be compiled on Windows (MSVC 2015, 2017) and on macOS.

One more question, what is the advantage of removing (empty) destructors and replacing them with 'virtual ~Manager() = default;'?

If one wants to write a real destructor later, one will have to introduce the destructor bodies again anyway.

Also, please leave the variable names as they are and don't introduce 'auto' everywhere. It's useful to know which type one is working with, even if it means that one has to write longer code.

Ok I will change that.

What are the advantages of the following?

+ Use List::empty or QList::isEmpty instead of comparing the length with 0.

A bit faster, because length need to be implemented with a for loop O(n) and empty only need to check if the first element exist O(1).

Please also make sure that the code can still be compiled on Windows (MSVC 2015, 2017) and on macOS.

I only use c++11 feature, so it shouldn't be a problem, but I will try to confirm with VM.

One more question, what is the advantage of removing (empty) destructors and replacing them with 'virtual ~Manager() = default;'?

If one wants to write a real destructor later, one will have to introduce the destructor bodies again anyway.

You are right, default only make sense, with copy and move constructor. I will revert this change.

Also, please leave the variable names as they are and don't introduce 'auto' everywhere. It's useful to know which type one is working with, even if it means that one has to write longer code.

Ok I will change that.

To make myself a little clearer, when you replace an iterator variable (typically called 'i') with a range-loop, can you try to find a better variable name than 'i'? I think it would improve the readability of the code.

What are the advantages of the following?

+ Use List::empty or QList::isEmpty instead of comparing the length with 0.

A bit faster, because length need to be implemented with a for loop O(n) and empty only need to check if the first element exist O(1).

That's true for a naive implementation of a list data structure. However, QList::size also runs in O(1).

See https://code.woboq.org/qt5/qtbase/src/corelib/tools/qlist.h.html#_ZNK9QListData4sizeEv

(and also QLinkedList::length actually)

I think we have to find the right balance between patch complexity, reviewing time, and benefits that result from the patch ;)

ognarb abandoned this revision.Oct 2 2018, 1:39 PM

I will split this revision in multiple revision.