anchor.diff:  encode_index(N) ->
       encode_integer(N, 7, 16#80).
   
  -encode_indname(N, Value, DoIndexing) ->
  -    {Prefix, FirstByte} = case DoIndexing of
  -                              true ->
  -                                  {6, 16#40};
  -                              false ->
  -                                  {4, 0}
  -                          end,
  +encode_indname(N, Value, true) ->
  +    encode_indname(N, Value, 6, 16#40);
  +encode_indname(N, Value, false) ->
  +    encode_indname(N, Value, 4, 0).
  +
  +encode_indname(N, Value, Prefix, FirstByte) ->
       Buf = encode_integer(N, Prefix, FirstByte),
       Buf2 = encode_string(Value),
       <<Buf/binary, Buf2/binary>>.
   
  -encode_newname(Name, Value, DoIndexing) ->
  -    FirstByte = case DoIndexing of
  -                    true ->
  -                        16#40;
  -                    false ->
  -                        0
  -                end,
  +encode_newname(Name, Value, true) ->
  +    encode_newname2(Name, Value, 16#40);
  +encode_newname(Name, Value, false) ->
  +    encode_newname2(Name, Value, 0).
  +
  +encode_newname2(Name, Value, FirstByte) ->
       Buf = <<FirstByte>>,
       Buf2 = encode_string(Name),
       Buf3 = encode_string(Value),
  
positive.code: 
  encode_integer(N, Prefix, FirstByte) ->
      K = (1 bsl Prefix) - 1,
      case N < K of
          true ->
              <<(N bor FirstByte)>>;
          false ->
              M = N - K,
              encode_integer_acc(M, <<(K bor FirstByte)>>)
      end.
  
  encode_integer_acc(N, Acc) when N < 128 ->
      <<Acc/binary, N>>;
  
negative.code:                   minsize=0,
                    contextupdate=false}.
  
  encode(Headers, Encoder=#hpackencoder{contextupdate=ContextUpdate})
    when ContextUpdate =:= true ->
      {Buf, Encoder2} = context_update(Encoder),
      encode(Headers, Buf, Encoder2);
  encode(Headers, Encoder) ->
      encode(Headers, <<>>, Encoder).
  
  encode(Headers, IniBuf, Encoder) ->
      {ok,
       lists:foldl(fun(Header, {Acc, Enc}) ->
                           {Chunk, Enc2} = encode_header(Header, Enc),
                           {<<Acc/binary, Chunk/binary>>, Enc2}
                   end, {IniBuf, Encoder}, Headers)}.
  
  
  context_update(Encoder=#hpackencoder{
                            minsize=MinSize,
                            context=#headercontext{maxsize=MaxSize}
                           }) when MinSize < MaxSize ->
      Buf = encode_table_size(MinSize),
      context_update(Buf, Encoder);
  context_update(Encoder) ->
      context_update(<<>>, Encoder).
  
  context_update(IniBuf, Encoder=#hpackencoder{
                                    context=#headercontext{maxsize=MaxSize}
                                   }) ->
      Buf = encode_table_size(MaxSize),
      {<<IniBuf/binary, Buf/binary>>, Encoder#hpackencoder{contextupdate=false}}.
  
  encode_header({Name, Value}, Encoder=#hpackencoder{context=Context}) ->
      case header:search(Name, Value, Context) of
  