(arg []byte)
| 432 | const argsLenMax = 4 |
| 433 | |
| 434 | func (nc *Conn) processMsgArgs(arg []byte) error { |
| 435 | // Use separate function for header based messages. |
| 436 | if nc.ps.hdr >= 0 { |
| 437 | return nc.processHeaderMsgArgs(arg) |
| 438 | } |
| 439 | |
| 440 | // Unroll splitArgs to avoid runtime/heap issues |
| 441 | a := [argsLenMax][]byte{} |
| 442 | args := a[:0] |
| 443 | start := -1 |
| 444 | for i, b := range arg { |
| 445 | switch b { |
| 446 | case ' ', '\t', '\r', '\n': |
| 447 | if start >= 0 { |
| 448 | args = append(args, arg[start:i]) |
| 449 | start = -1 |
| 450 | } |
| 451 | default: |
| 452 | if start < 0 { |
| 453 | start = i |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | if start >= 0 { |
| 458 | args = append(args, arg[start:]) |
| 459 | } |
| 460 | |
| 461 | switch len(args) { |
| 462 | case 3: |
| 463 | nc.ps.ma.subject = args[0] |
| 464 | nc.ps.ma.sid = parseInt64(args[1]) |
| 465 | nc.ps.ma.reply = nil |
| 466 | nc.ps.ma.size = int(parseInt64(args[2])) |
| 467 | case 4: |
| 468 | nc.ps.ma.subject = args[0] |
| 469 | nc.ps.ma.sid = parseInt64(args[1]) |
| 470 | nc.ps.ma.reply = args[2] |
| 471 | nc.ps.ma.size = int(parseInt64(args[3])) |
| 472 | default: |
| 473 | return fmt.Errorf("nats: processMsgArgs Parse Error: '%s'", arg) |
| 474 | } |
| 475 | if nc.ps.ma.sid < 0 { |
| 476 | return fmt.Errorf("nats: processMsgArgs Bad or Missing Sid: '%s'", arg) |
| 477 | } |
| 478 | if nc.ps.ma.size < 0 { |
| 479 | return fmt.Errorf("nats: processMsgArgs Bad or Missing Size: '%s'", arg) |
| 480 | } |
| 481 | return nil |
| 482 | } |
| 483 | |
| 484 | // processHeaderMsgArgs is for a header based message. |
| 485 | func (nc *Conn) processHeaderMsgArgs(arg []byte) error { |
no test coverage detected