ottypes / json0

Version 0 of the JSON OT type
447 stars 64 forks source link

why need both common and common2 in json0.transformComponent? #35

Open happy15 opened 3 years ago

happy15 commented 3 years ago

Hi there, some questions when reading the source code:

  1. From the implementation I can see that json0.commonLenghtForOps(a,b) is not symmetry, i.e.commonLengthForOps(a,b) may not be the same as commonLengthForOps(b,a), why is that? From the comment above ("Returns the common length of the paths of ops a and b") I cannot get the point.

  2. Since json0.commonLenghtForOps(a,b) is not symmetry, I can see that common and common2 in json0.transformComponent(dest,c,otherC,type) may not be the same. But what's their respective purposes? Without some hint, it's hard to figure out by just reading the code, since the code includes many things, such as backward compatibility, code path merge, etc.

Thanks in advance and looking forward to the reply.