← Back to team overview

kicad-developers team mailing list archive

[RFC] Remove counters from general section of pcbnew file

 

I would like to remove the counters of the general section in the KiCAD
PCBNew's file format. By counters I mean the
links, no_connects, drawings, tracks, zones, modules and nets elements in
the general section. E.g:

(general
    *(links 280)*
    *(no_connects 0)*
    (area 29.899999 29.899999 225.100001 106.600001)
    (thickness 1.6)
    *(drawings 67)*
    *(tracks 987)*
    *(zones 0)*
*    (modules 108)*
*    (nets 81)*
  )

When checking PCB designs into a SCM these counters make it virtually
impossible to handle merges, since they pretty much always cause merge
conflicts. Even if someone commits a small fix on the other side of the
board another person is working on, this fix could (and typically does)
cause one of the counters to change, resulting in a merge conflict. The
only ways to fix the conflict is manually calculating the new values for
the conflicting counters or re-doing the fix. Both methods are a pain for
people not that familiar with the SCM (most people).

These counters are also redundant, potentially causing inconsistency
because of potential bugs in PCBNew or by altering the PCB file manual
(something I often end up doing due to limitations of PCBNew) or using
third-party tools like my company's tooling
<https://github.com/productize/kicad-parse-gen> (again, to cope with
limitations in PCBNew).

By looking into the code I found that only the "nets" and "no_connects"
counters are actually parsed by PCBNew, the others are ignored (see
pcb_parser:cpp:~600). The netlist counter is only used to set an initial
size for the `m_netCodes` map. When finding new netlists this map is
resized, so it should work (inefficiently) without it. Setting a big enough
value or resizing using grow algorithm
<https://en.wikipedia.org/wiki/Dynamic_array> (a bit more memory intensive)
or counting the nets in the file (more io intensive) would make it more
performant.

The amount of unconnected nets can just be calculated by building the
board's ratsnest (PCB_BASE_FRAME::Build_Board_Ratsnest) after parsing it.

I would like to commit a patch for this, but I would like to discuss how
backwards compatibility could be handled first.

Greeting
Seppe Stas

Follow ups