comparison src/misc2.c @ 6929:e55929fca0cf v7.4.783

patch 7.4.783 Problem: copy_chars() and copy_spaces() are inefficient. Solution: Use memset() instead. (Dominique Pelle)
author Bram Moolenaar <bram@vim.org>
date Fri, 17 Jul 2015 13:22:51 +0200
parents 58d9f967ae1a
children 7758d6245c3a
comparison
equal deleted inserted replaced
6928:e607a8d58e64 6929:e55929fca0cf
1594 p++; 1594 p++;
1595 } 1595 }
1596 } 1596 }
1597 1597
1598 return res; 1598 return res;
1599 }
1600 #endif
1601
1602 /*
1603 * copy a space a number of times
1604 */
1605 void
1606 copy_spaces(ptr, count)
1607 char_u *ptr;
1608 size_t count;
1609 {
1610 size_t i = count;
1611 char_u *p = ptr;
1612
1613 while (i--)
1614 *p++ = ' ';
1615 }
1616
1617 #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
1618 /*
1619 * Copy a character a number of times.
1620 * Does not work for multi-byte characters!
1621 */
1622 void
1623 copy_chars(ptr, count, c)
1624 char_u *ptr;
1625 size_t count;
1626 int c;
1627 {
1628 size_t i = count;
1629 char_u *p = ptr;
1630
1631 while (i--)
1632 *p++ = c;
1633 } 1599 }
1634 #endif 1600 #endif
1635 1601
1636 /* 1602 /*
1637 * delete spaces at the end of a string 1603 * delete spaces at the end of a string