def _optimize_using_move(prev_item, item):
    """Optimises JSON patch by using ``move`` operation instead of
    ``remove` and ``add`` against the different paths but for the same value."""
    prev_item['op'] = 'move'
    move_from, move_to = [(item['path'], prev_item['path']), (prev_item[
        'path'], item['path'])][item['op'] == 'add']
    if item['op'] == 'add':
        prev_item['from'] = move_from
        prev_item['path'] = move_to
    else:
        head, move_from = move_from.rsplit('/', 1)
        move_from = int(move_from) - 1
        prev_item['from'] = head + '/%d' % move_from
        prev_item['path'] = move_to
