Explorer

core.decode-value-fields

description
Reads count more record fields (a string key then a value, core.decode-value-at) from index on after fields. It reads the first half and then the rest, so a long record does not need deep recursion
type
Fn(
  text: String,
  bytes: List<Number>,
  index: Number,
  count: Number,
  fields: List<Record{key: String, value: @core.value}>
) -> Union{#none, #some(Record{fields: List<Record{key: String, value: @core.value}>, next: Number})}
expression
fn(text$0, bytes$1, index$2, count$3, fields$4) =>
  match @core.less-than-or-equal(left: $3, right: 1) {
    true =>
      match @core.less-than-or-equal(left: $3, right: 0) {
        true =>
          #some({fields: $4, next: $2}),
        false =>
          match @core.decode-value-at(text: $0, bytes: $1, index: $2) {
            #some(key$5) =>
              match $5.value {
                #string(name$6) =>
                  match @core.decode-value-at(text: $0, bytes: $1, index: $5.next) {
                    #some(read$7) =>
                      #some({fields: @core.list-append(list: $4, item: {key: $6, value: $7.value}), next: $7.next}),
                    #none(_) =>
                      #none
                  },
                _ =>
                  #none
              },
            #none(_) =>
              #none
          }
      },
    false =>
      let half$8 = @core.divide(left: $3, right: 2);
      match @core.decode-value-fields(text: $0, bytes: $1, index: $2, count: $8, fields: $4) {
        #some(first$9) =>
          @core.decode-value-fields(text: $0, bytes: $1, index: $9.next, count: @core.minus(left: $3, right: $8), fields: $9.fields),
        #none(_) =>
          #none
      }
  }
visibility
public
core.decode-value-fields (project definy, branch quote-encoded-parts, snapshot LbKb9vIRs5vdtsu6TiOqZ_NMUZJ6k1s6WlbZOc6x3-I)
id: OHpNDP64MUUay7AzQkUt6p7pdGnt_BnmZBVQS-v_zXY
content hash: YHg6epvi9QOW4DcK7I6Uq0Ku-C4dARUGK6-RWmDR0CY