@@ -152,9 +152,7 @@ variableValues):
152
152
- Let {pending} be an empty list.
153
153
- If {initialDefers} is not an empty object:
154
154
- Let {id} be {nextId} and increment {nextId} by one.
155
- - Let {path} be the longest common path prefix list for every path list key in
156
- {initialDefers}, or the empty list if no such list exists.
157
- - TODO: This really needs rewording!
155
+ - Let {path} be {LongestCommonPathPrefix(initialDefers)}.
158
156
- Let {pendingPayload} be an unordered map containing {id}, {path}.
159
157
- Add {pendingPayload} to {pending}.
160
158
- Let {defers} be {initialDefers}.
@@ -229,9 +227,7 @@ variableValues):
229
227
{incrementalPayload} to {incremental}.
230
228
- If {batchDefers} is not an empty object:
231
229
- Let {id} be {nextId} and increment {nextId} by one.
232
- - Let {path} be the longest common path prefix list for every path list
233
- key in {batchDefers}, or the empty list if no such list exists.
234
- - TODO: This really needs rewording!
230
+ - Let {path} be {LongestCommonPathPrefix(batchDefers)}.
235
231
- Let {pendingPayload} be an unordered map containing {id}, {path}.
236
232
- Add {pendingPayload} to {pending}.
237
233
- Let {defers} be {batchDefers}.
@@ -277,9 +273,7 @@ variableValues):
277
273
- Append {incrementalPayload} to {incremental}.
278
274
- If {childDefers} is not an empty object:
279
275
- Let {id} be {nextId} and increment {nextId} by one.
280
- - Let {path} be the longest common path prefix list for every path list
281
- key in {childDefers}, or the empty list if no such list exists.
282
- - TODO: This really needs rewording!
276
+ - Let {path} be {LongestCommonPathPrefix(childDefers)}.
283
277
- Let {pendingPayload} be an unordered map containing {id}, {path}.
284
278
- Add {pendingPayload} to {pending}.
285
279
- Let {defers} be {childDefers}.
@@ -300,6 +294,26 @@ variableValues):
300
294
- {FlushStream(false)}.
301
295
- Complete {responseStream}.
302
296
297
+ LongestCommonPathPrefix(map):
298
+
299
+ - Let {paths} be a list of the keys of {map}.
300
+ - Let {longestCommonPathPrefix} be the first entry in {paths}.
301
+ - For each {path} in paths:
302
+ - Let {commonPrefix} be an empty list.
303
+ - Let {length} be the least of the length of {path} and the length of
304
+ {longestCommonPathPrefix}.
305
+ - Let {index} be {0}.
306
+ - While {index} is less than {length} and the entries at position {index} in
307
+ both {path} and {longestCommonPathPrefix} are both equal, let {pathEntry} be
308
+ this value:
309
+ - Add {pathEntry} to {commonPrefix}.
310
+ - Let {longestCommonPathPrefix} be {commonPrefix}.
311
+ - Return {longestCommonPathPrefix}.
312
+
313
+ TODO: Consider rewording to something like: Let {longestCommonPathPrefix} be the
314
+ longest list such that every entry in {paths} starts with
315
+ {longestCommonPathPrefix}. Note: This may be the empty list.
316
+
303
317
### Mutation
304
318
305
319
If the operation is a mutation, the result of the operation is the result of
0 commit comments